Because of the requirements of project development, the database design has to use the remote mode. However, the remote settings of the database are not that simple. The database of this project is MYSQL5.0. At the beginning, I thought that a remote connection can be performed as long as the database server is installed. However, MYSQL is set for user security. By default, the system does not allow remote user connection and can only be performed locally.
Because of the requirements of project development, the database design has to use the remote mode. However, the remote settings of the database are not that simple. The database of this project is MYSQL5.0. At the beginning, I thought that a remote connection can be performed as long as the database server is installed. However, MYSQL is set for user security. By default, the system does not allow remote user connection and can only be performed locally.
Because of the requirements of project development, the database design has to use the remote mode. However, the remote settings of the database are not that simple. The database of this project is MYSQL5.0. At the beginning, I thought that a remote connection can be performed as long as the database server is installed. However, MYSQL is set for user security. The default system setting is that remote user connection is not allowed, only Local Users can be connected.
You only need to set the HOST value of the system administrator user to allow remote access.
Method 1:
Log On with the root user, and then:
Grant all privileges on *. * to create the username @ "%" identified by "password ";
Flush privileges; * refresh the content just now *
Format: grant permission on database name. Table name to user @ login host identified by "User Password ";
@ Followed by the IP address (or host name) % of the client accessing mysql represents any client. If you enter localhost
Local access (this user cannot remotely access the mysql database ).
You can also set the remote access permission for existing users. As follows:
Use mysql;
Update db set host = '%' where user = 'username'; (if the name is host = localhost, this user does not have the remote access permission)
Flush privileges;
Grant all privileges on *. * TO 'myuser' @ '%' identified by 'mypassword' with grant option;
The above method is found on the Internet.
The following is my own setting method, which is a visual operation.
Method 2:
There is a mysql database under the connection, which is the system database. A user data table stores user information that can be operated on the database.
Open the table, as shown in. As long as we change the host value before the user name to "%", we can allow users to access the database from any IP address.
The principle is the same, but it will be simpler. If the connection still fails, restart the mysql service.