gpt4 book ai didi

mysql - 无法从linux xshell直接插入mysql数据库

转载 作者:行者123 更新时间:2023-11-29 22:58:56 24 4
gpt4 key购买 nike

我已运行以下命令将数据插入我的 mysql 数据库。 sql查询没问题。但运行查询后,会提示输入密码。但在我的数据库中没有设置密码。所以如果我按回车键而不写任何东西那么它就会插入数据。我怎样才能避免这个提示。这意味着我希望该命令能够直接工作。不会提示输入密码。

Enter password: 
linux-pott:/opt/lampp/htdocs # mysql -uroot -p -e 'insert into dialer_rate(date_time,time,mno,trx_type,trx_result,trx_value) values("2015-02-19","12:14","air","N/A","Not_Running",0) ' bkash
Enter password:
linux-pott:/opt/lampp/htdocs #

最佳答案

删除 cmd 中的选项 -p:

linux-pott:/opt/lampp/htdocs # mysql -u root -e 'insert into dialer_rate(date_time,time,mno,trx_type,trx_result,trx_value) values("2015-02-19","12:14","air","N/A","Not_Running",0) ' bkash

来自官方documentation :

For a long option that takes a value, separate the option name and the value by an “=” sign. For a short option that takes a value, the option value can immediately follow the option letter, or there can be a space between: -hlocalhost and -h localhost are equivalent. An exception to this rule is the option for specifying your MySQL password. This option can be given in long form as --password=pass_val or as --password. In the latter case (with no password value given), the program prompts you for the password. The password option also may be given in short form as -ppass_val or as -p. However, for the short form, if the password value is given, it must follow the option letter with no intervening space. The reason for this is that if a space follows the option letter, the program has no way to tell whether a following argument is supposed to be the password value or some other kind of argument. Consequently, the following two commands have two completely different meanings:

关于mysql - 无法从linux xshell直接插入mysql数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28600151/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com