Enable MySQL remote connection in Linux
For security reasons, the root account can only be accessed locally, but the root remote access permission may be required during development. The basic steps are as follows:
1. log on to mysql and grant remote access permissions to the root user. run the following command:
Mysql> grant all privileges on *. * TO root @ "%" identified by "root ";
Mysql> flush privileges;
In the first sentence, "%" indicates that any host can be remotely logged on to the server for access. If you want to restrict access to only one machine, replace it with the corresponding IP address, for example:
Grant all privileges on *. * TO root @ "172.16193.25" identified by "root ";
The second statement indicates that the permission data is reloaded from the grant table of the mysql database. Because MySQL puts all permissions in the cache, it needs to be reloaded after modification.
2. modify/etc/mysql/my. cnf with the root user permission. Find the file:
- Bind-address = 127.0.0.1
Comment it out and save it.
3. restart the MySQL server. Run the following commands:
#/Usr/bin/mysqladmin-u root-p shutdown
#/Usr/bin/mysqld_safe &
If mysqladmin and mysql_safe are not in the/usr/bin directory, you can run the whereis command to find them. for example:
# Whereis mysqladmin
Mysqladmin:/usr/bin/mysqladmin/usr/share/man/man1/mysqladmin.1.gz
After completing the preceding three steps, you can connect to the database through a remote machine.
Done!