今天在尝试运行mysqld_report stop的时候,发现无法停止mysql,日志中的错误如下
Stopping MySQL servers mysqladmin: [Warning] Using a password on the command line interface can be insecure. mysqladmin: connect to server at 'localhost' failed error: 'Access denied for user 'root'@'localhost' (using password: YES)' mysqladmin: [Warning] Using a password on the command line interface can be insecure. mysqladmin: connect to server at 'localhost' failed error: 'Access denied for user 'root'@'localhost' (using password: YES)' mysqladmin: [Warning] Using a password on the command line interface can be insecure. mysqladmin: connect to server at 'localhost' failed error: 'Access denied for user 'root'@'localhost' (using password: YES)' mysqld_multi log file version 2.16; run: Tue Jan 17 14:19:01 2017
可以看出,肯定是使用mysqladmin无法登录的问题。
但是,我的my.cnf配置文件中,已经指定了user和password,整个文件内容如下
[client] port=3306 socket=/tmp/mysql.sock [mysqld_multi] user=root password=root mysqld=/usr/local/mysql/bin/mysqld_safe mysqladmin=/usr/local/mysql/bin/mysqladmin log=/home/mysql/mysqld_multi.log [mysqld] basedir=/usr/local/mysql sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES [mysqld3306] mysqld=mysqld mysqladmin=mysqladmin datadir=/home/mysql/mysql3306/data port=3306 server_id=3306 socket=/tmp/mysql3306.sock log-output=file slow_query_log = 1 long_query_time = 1 slow_query_log_file = /home/mysql/mysql3306/log/slow.log log-error = /home/mysql/mysql3306/log/error.log binlog_format = mixed log-bin = /home/mysql/mysql3306/log/mysql3306_bin [mysqld3307] mysqld=mysqld mysqladmin=mysqladmin datadir=/home/mysql/mysql3307/data port=3307 server_id=3307 socket=/tmp/mysql3307.sock log-output=file slow_query_log = 1 long_query_time = 1 slow_query_log_file = /home/mysql/mysql3307/log/slow.log log-error = /home/mysql/mysql3307/log/error.log binlog_format = mixed log-bin = /home/mysql/mysql3307/log/mysql3307_bin [mysqld3308] mysqld=mysqld mysqladmin=mysqladmin datadir=/home/mysql/mysql3308/data port=3308 server_id=3308 socket=/tmp/mysql3308.sock log-output=file slow_query_log = 1 long_query_time = 1 slow_query_log_file = /home/mysql/mysql3308/log/slow.log log-error = /home/mysql/mysql3308/log/error.log binlog_format = mixed log-bin = /home/mysql/mysql3308/log/mysql3308_bin
其实,此时的配置有问题不对“password=root”应该改为“pass=root”,文件如下
[client] port=3306 socket=/tmp/mysql.sock [mysqld_multi] user=root pass=root mysqld=/usr/local/mysql/bin/mysqld_safe mysqladmin=/usr/local/mysql/bin/mysqladmin log=/home/mysql/mysqld_multi.log [mysqld] basedir=/usr/local/mysql sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES [mysqld3306] mysqld=mysqld mysqladmin=mysqladmin datadir=/home/mysql/mysql3306/data port=3306 server_id=3306 socket=/tmp/mysql3306.sock log-output=file slow_query_log = 1 long_query_time = 1 slow_query_log_file = /home/mysql/mysql3306/log/slow.log log-error = /home/mysql/mysql3306/log/error.log binlog_format = mixed log-bin = /home/mysql/mysql3306/log/mysql3306_bin [mysqld3307] mysqld=mysqld mysqladmin=mysqladmin datadir=/home/mysql/mysql3307/data port=3307 server_id=3307 socket=/tmp/mysql3307.sock log-output=file slow_query_log = 1 long_query_time = 1 slow_query_log_file = /home/mysql/mysql3307/log/slow.log log-error = /home/mysql/mysql3307/log/error.log binlog_format = mixed log-bin = /home/mysql/mysql3307/log/mysql3307_bin [mysqld3308] mysqld=mysqld mysqladmin=mysqladmin datadir=/home/mysql/mysql3308/data port=3308 server_id=3308 socket=/tmp/mysql3308.sock log-output=file slow_query_log = 1 long_query_time = 1 slow_query_log_file = /home/mysql/mysql3308/log/slow.log log-error = /home/mysql/mysql3308/log/error.log binlog_format = mixed log-bin = /home/mysql/mysql3308/log/mysql3308_bin