我正在准备一个自动化的 shell 脚本,但在 shell 脚本中运行的 MySQL 命令有一个警告:在命令行界面上使用密码可能是不安全的,并且 .sock 错误。请帮助我...我的代码是:
user="root"
password="7layer"
db="mysql"
mysql -u "$user" -p"$password" <<EOF
use $db;
mysqld_safe --skip-grant-tables
update user set Password=PASSWORD('7layer') where user='root';
UPDATE mysql.user SET password_expired='N' WHERE User='root';
FLUSH PRIVILEGES;
exit;
EOF
输出是:
Starting MySQL. [ OK ]
Shutting down MySQL.. [ OK ]
Warning: Using a password on the command line interface can be insecure.
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
[root@autoinstallapi AutoInstall]#