Home >Database >Mysql Tutorial >How to set up remote access to MySQL on Linux
MySQL is a commonly used relational database management system. When developing or deploying applications, we need to set up MySQL remote access settings according to the situation. MySQL remote access settings are particularly important when collaborating on multiple computers or servers.
The default setting of MySQL is to only allow local access. If we need to access MySQL from another computer or server, additional access settings are required.
Below we will introduce in detail how to set up remote access to MySQL on a Linux system.
Before setting up MySQL remote access, we need to confirm the following prerequisites:
(1 ) Make sure MySQL is up and running.
(2) Confirm which IP address the MySQL server is installed on.
(3) Confirm the version and port number of MySQL.
(4) Make sure you have permission to access MySQL.
2.1 Turn on remote access to the MySQL server
When turning on MySQL remote access, we need to enter MySQL The configuration file my.cnf is generally located in /etc/mysql/my.cnf.
Add the following content under the [mysqld] tag of the my.cnf file:
bind-address = server IP address
Note: Replace "server IP address" into the IP address of the MySQL server.
2.2 Update MySQL user permissions
When performing remote access to MySQL, we also need to update the MySQL user permissions. We can update through the following command:
GRANT ALL PRIVILEGES ON database name.* TO 'Username'@'Remote Access IP Address' IDENTIFIED BY 'Password';
Note: Change " Replace "Username", "Remote Access IP Address", "Password" and "Database Name".
After completing the MySQL remote access settings, we need to test to ensure that the remote access settings have taken effect.
We can test through the following command:
mysql -h server IP address -u username -p
After executing the command, you will be prompted to enter the password, enter it correctly After entering the password, you can connect to the MySQL server.
When setting up MySQL remote access, we need to perform the following steps:
(1) Confirm that the MySQL server has been started and running.
(2) Confirm which IP address the MySQL server is installed on.
(3) Confirm the version and port number of MySQL.
(4) Enable remote access to the MySQL server.
(5) Update MySQL user permissions.
(6) Test whether the MySQL remote access settings take effect.
In collaborative development, MySQL remote access settings allow developers to work together on different machines, improving development efficiency and collaboration effects.
The above is the detailed content of How to set up remote access to MySQL on Linux. For more information, please follow other related articles on the PHP Chinese website!