- 论坛徽章:
- 0
|
增加参数:“-h 127.0.0.1”,输入密码成功登录数据库。- [root@Web ~]# mysql -uroot -p -S /data/3306/mysql.sock -h 127.0.0.1
- Enter password:
- Welcome to the MySQL monitor. Commands end with ; or \g.
- Your MySQL connection id is 2
- Server version: 5.1.62-log Source distribution
- Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
- Oracle is a registered trademark of Oracle Corporation and/or its
- affiliates. Other names may be trademarks of their respective
- owners.
- Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
- mysql> select user,host,password from mysql.user;
- +------+-----------+-------------------------------------------+
- | user | host | password |
- +------+-----------+-------------------------------------------+
- | root | Web | *832EB84CB764129D05D498ED9CA7E5CE9B8F83EB |
- | root | 127.0.0.1 | *832EB84CB764129D05D498ED9CA7E5CE9B8F83EB |
- +------+-----------+-------------------------------------------+
- 2 rows in set (0.00 sec)
复制代码 为MySQL添加root远程登录权限(3306实例的登录密码是“111”):
- mysql> use mysql;
- Database changed
- mysql> GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY "111";
- Query OK, 0 rows affected (0.00 sec)
- mysql> flush privileges;
- Query OK, 0 rows affected (0.00 sec)
- mysql> quit
- Bye
- [root@Web ~]# mysql -uroot -p -S /data/3306/mysql.sock
- Enter password:
- Welcome to the MySQL monitor. Commands end with ; or \g.
- Your MySQL connection id is 9
- Server version: 5.1.62-log Source distribution
- Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
- Oracle is a registered trademark of Oracle Corporation and/or its
- affiliates. Other names may be trademarks of their respective
- owners.
- Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
- mysql> select user,host,password from mysql.user;
- +------+-----------+-------------------------------------------+
- | user | host | password |
- +------+-----------+-------------------------------------------+
- | root | % | *832EB84CB764129D05D498ED9CA7E5CE9B8F83EB |
- | root | localhost | *832EB84CB764129D05D498ED9CA7E5CE9B8F83EB |
- | root | 127.0.0.1 | *832EB84CB764129D05D498ED9CA7E5CE9B8F83EB |
- +------+-----------+-------------------------------------------+
- 3 rows in set (0.00 sec)
- mysql> quit
- Bye
复制代码
解决问题后,我就怀疑是清理多余账号时,出现误删除,导致登录数据库报错,原因可能是root失去在本地登录数据库的权限。
|
|