Problem 1: the local host connection is normal, but you cannot log on to the MySQL database from other computers!
The following is an excerpt from/etc/mysql/my. cnf:
# Instead of skip-networking the default is now to listen only on # localhost which is more compatible and is not less secure. bind-address = 10.0.0.1 # 127.0.0.1
|
It indicates that MySQL is set to only listen on localhost by default. Therefore, if the login MySQL Client and MySQL Server are not on the same computer, MySQL will not respond. Therefore, you need to modify the bind-address here to the external IP address of this computer.
Problem 2: ERROR 1045 (28000): Access denied for user 'root' @ '10. 0.0.1 '(using password: YES )!
This is also quite interesting. First, let's look at the information in the original system table:
mysql> USE mysql; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A
Database changed
mysql> SELECT Host FROM user WHERE user='root'; +-----------+ | Host | +-----------+ | sharkwang | | localhost | +-----------+ 2 rows in set (0.00 sec)
|
Well, in addition to localhost, there is actually a sharkwang, And I used IP instead of hostname to connect to it!
Therefore, there are two solutions:
1. Modify the/etc/hosts file on the computer where the MySQL Client is located and add the hosting between hostname and IP address.
Logon method: shell> mysql-h <mysql_server_hostname>-u root-p
2. Add a record to the user table of the MySQL database. For details, refer:
SELECT * FROM user WHERE User = 'root' AND Host = 'localhost'
Then, change the Host value to the MySQL Server's external IP address.
Logon method: shell> mysql-h <mysql_server_ip>-u root-p