The first time I configured mysql in Linux is really tortuous, so I would like to record
Step 1: download and install MySQL
Terminal input: sudo apt-get install mysql-server mysql-client
Step 2: confirm the address of the MySQL host
Terminal input: ifconfig. the inet address of eth0 is
Then remotely connect to port 3306 of the above ip address (if it has not been changed). If the connection is successful, it will certainly be OK. If the connection fails, the following problems may occur:
Error 2003 ]:
This error occurs because IP binding is enabled in the MySQL configuration and only access from the Local Machine (127.0.0.1) is allowed. Therefore, you need to modify this configuration.
Sudo vi/etc/mysql/my. cnf
Find the bind-address = 127.0.0.1 line and comment it (add # At the beginning of the line)
Save and exit. Restart MySQL.
Sudo/etc/init. d/mysql restart
Error 1130 ]:
This error occurs because the account used for remote logon is not authorized to log on to the current IP address. To put it bluntly, each account has one or more IP addresses allowed to log on, for example, the root account has localhost and 127.0.0.1 by default, but far
The IP address of the ECS instance is not allowed. Therefore, you must add the logon permission for this IP address to the account you are using.
First, let's take a look at the IP address logon permissions of this account.
Log on to mysql on Ubuntu Terminal
Enter mysql-u root-p
Enter Password
After successful login, enter the following command:
1. use mysql
2. select Host from user where user = 'user name to be queried, such as root'
The query results will list the IP addresses allowed by the user root to log on. The error 1130 is reported on the current remote machine because the IP address is not allowed. Therefore, there are two options for remote login. The first option is to add the IP address of the remote machine, and the second option is to directly add an arbitrary IP address (% ), access from any remote address depends on your needs.
Add method:
Because the statement for copying a whole record is too long and troublesome, you can simply change one of localhost and 127.0.0.1 to the address to be released.
For example:
Update user set Host = '%' where Host = '192. 100'; (Note that the end is a semicolon)
In this way, change the host of the record of host = 127.0.0.1 to % (representing any ip address)
Then
Flush privileges; (note that the last Semicolon is used to refresh the permission .)
Restart the MYSQL service.
Sudo/etc/init. d/mysql restart