Open MySQL remote connection under Linux
Based on security considerations The root account is generally only accessible locally, but it may be necessary to open the root remote access permission during the development process. Here are the basic steps:
1. Log in to MySQL, authorize remote access for root, and execute the following command:
Mysql> GRANT All privileges on * * to [email protected] '% ' identified by ' root ';
mysql> flush Privileges;
The "%" in the first sentence indicates that any host can be accessed remotely to the server. If you want to restrict access to only one machine, replace it with the appropriate IP, such as:
GRANT all privileges on * * to [e-mail protected] "172.168.193.25" identified by "root";
The second sentence reloads the permission data from the grant table in the MySQL database. Because MySQL puts permissions in the cache, it needs to be reloaded after the changes have been made.
2, modify/etc/mysql/my.cnf, need root user rights. Locate the file in:
- Bind-address = 127.0.0.1
Comment It out and save it.
3. Restart the MySQL server. Follow these few commands:
#/usr/bin/mysqladmin-u Root-p shutdown
#/usr/bin/mysqld_safe &
If Mysqladmin and Mysql_safe are not in the/usr/bin directory, they can be found through the Whereis command, for example:
# Whereis Mysqladmin
Mysqladmin:/usr/bin/mysqladmin/usr/share/man/man1/mysqladmin.1.gz
After performing the three steps above, the database can be connected via a remote machine.
done!