Enable remote access to the MySQL database





We experience the following error when logging in to the database remotely from our computer






The reason is that MySQL does not allow remote access by default. If we want to implement remote access, we need to modify the MySQL configuration file mysqld.cnf on the remote server.


Enter the command on the remote server terminal:





Comment the line bind-address = 127.0.0.1 and save and exit. MySQL > restart MySQL





We go back to our computer and log in again. The following error occurs again:









The root user can only log in locally when installing MySQL.





After logging in to mysql, enter the following commands:









Host indicates the host, user indicates the user, and authentication_string indicates the encrypted password.


You can see that the host corresponding to the root user is localhost, indicating that the root user can only log in locally.


For remote access, we need to change localhost to %. We don’t normally change root Settings, so we create a new user for remote access.








We can use the newly created user login to achieve remote access.






More Java learning materials can be found at itheimaGZ