mysql远程连接时提示失败
[root@mysql ~]# /usr/local/mysql/bin/mysql -ubackup -p123456 -h 192.168.6.36
Warning: Using a password on the command line interface can be insecure.
ERROR 1045 (28000): Access denied for user ‘backup‘@‘mysql‘ (using password: YES)
原因:我通过装好MySQL的虚拟机,克隆并修改了主机名,导致远程无法登陆;
[root@mysqlslave ~]# mysql
mysql> select user,host from mysql.user;
+------------+-----------+
| user | host |
+------------+-----------+
| backup | % |
| test | % |
| backup | 127.0.0.1 |
| root | 127.0.0.1 |
| ebnewslave | 192.168.% |
| root | ::1 |
| | localhost |
| backup | localhost |
| root | localhost |
| test | localhost |
| | mysql |
| root | mysql |
+------------+-----------+
解决方法:
修改root用户和“ ”对应的host为原机器名的值
update mysql.user set host=‘mysqlslave‘ where user=‘root‘ and host=‘mysql‘;
update mysql.user set host=‘mysqlslave‘ where user=‘ ‘ and host=‘mysql‘;
flush privileges ; ---注,如果不刷新权限和重启数据库,权限是不生效的。
ERROR 1045 (28000): Access denied for user 'backup'@'mysql' (using password: YES)
原文地址:http://yiqiuyu.blog.51cto.com/3228402/1655743