Set remote access in mysql5.7 and remote access in mysql5.7
In mysql5.7, setting remote access is not the same as setting up a user to grant permissions on the Internet. For example, the following example shows how to grant permissions to the user, which may be available in the previous version, but I have never been able to perform this operation on mysql. This is annoying for a long time !!! Project delay !!
I. The original remote access method
By default, Mysql cannot be accessed through a remote machine. The following configuration allows you to enable remote access.
On the MySQL Server:
Run the mysql command to enter the mysql command mode,
SQL code
- Mysql> use mysql;
- Mysql> grant all on *. * TO user @ '%' identified by '000000' with grant option;
# Allow any IP address (% above) to access the MySQL Server using the admin account and password (admin ).
# You must add an account like this to log on remotely. The root account cannot be remotely logged on. You can only log on locally.
Remote Access:
- Mysql-h172.21.5.29-uuser-p123456
- // 172.21.5.29 is the IP address of the MySQL Server, and the user is the remote access account set on 172.21.5.29.
In addition, you can simulate remote access on a machine, that is, open several more terminals to test whether remote access is allowed.
I found a problem. If you have finished executing the above command, you will be running localhost locally. Execute:
- Mysql-hlocalhost-uadmin-padmin
The result is failed.
The above % does not include localhost.
Therefore, you must add the following command:
Mysql> grant all on *. * TO admin @ 'localhost' identified by 'admin' with grant option;
2. Set remote access in mysql5.7
After setting it according to the above method, I found that mysql-h cannot be remotely accessed. I modified the/etc/my. cnf configuration file
# Comment out skip-networking
Bind-address = 0.0.0.0
However, it is useless!
I think it's almost time!
Later, I went straight to his configuration file: in the/etc/mysql folder.
Click my. cnf in the diagram:
#
# * IMPORTANT: Additional settings that can override those from this file!
# Configurations in other places can overwrite the configurations in this file
# The files must end with '. cnf', otherwise they'll be ignored.
#
! Includedir/etc/mysql/conf. d/
! Includedir/etc/mysql. conf. d/
I'm curious about the last two paths of the file. I went to see: conf. d /:
There is a configuration file in it. Open it and find that there is a [mysql], and there is nothing.
Let's look at another one:
There is also a configuration file, opened to find a surprise, there is a sentence here:
There is a feeling of seeing every day in an instant !!! You can see from its annotations that only local connections are allowed. The problem lies in this !!
Comment out bind-address: # bind-address =...
Restart the mysql service. remote connection:
- Mysql-h172.17.0.1-uuser-p
// My user name is: user
Finally, haha !!
It took two days !!! I'm convinced of mysql !!