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

标签 mysql linux opensuse

我已运行以下命令将数据插入我的 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/

相关文章:

mysql - 是否可以将 EntityFramework 与 MemSQL 一起使用?

mysql 正则表达式查询挂起,但在 mysql 进程重新启动时显示结果

使用连接和多个 AND 的 MySQL 查询不太有效

Python:子进程调用无法识别 * 通配符?

linux - 如何将文件移动到参数路径?

php 使用上一页中的参数选择查询

linux - 将文件从目录堆栈中的目录复制到当前目录

linux - Ubuntu 14.04 CUDA 8.0 未满足的依赖关系

php - 在 Linux 上安装 CakePHP 时出现问题

r - 问题 : Installing R on openSUSE Leap 15. 0: "liblzma library and headers are required"