当我尝试通过命令行连接到远程MYSQL数据库时,尽管出现警告,该方法仍能正常工作:

/sdzf => mysql -h db3  -u auser -ppassword DB_6 -A
Warning: Using a password on the command line interface can be insecure.


但是,运行脚本不起作用

/sdzf => mysql -h db3  -u auser -ppassword DB_6 -A< findrec.sql
Warning: Using a password on the command line interface can be insecure.
ERROR 1045 (28000) at line 1: Access denied for user 'auser'@'50.206.86.74'
(using password: YES)

最佳答案

尽管我的登录语句包含数据库名称,但在批处理模式下运行时,我仍然需要在SQL脚本中首先指向该数据库:

USE DB_6;

如果我首先使用相同的脚本“ mysql -h db3 -u auser -ppassword DB_6 -A”登录,则无需在SQL中指向数据库。

关于mysql - 如何从命令行使用密码运行MYSQL脚本?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/38573505/

10-11 22:39
查看更多