MySQL Remote Access
====================================================================================
To configure remote access for MySQL, you need to ensure that MySQL is configured to accept remote connections and that your firewall and MySQL user permissions are set up correctly.
Configure MySQL Server to Allow Remote Connections
1. Bind Address
The bind-address option in the MySQL configuration file specifies which network interfaces MySQL will listen on for incoming connections. By default, this is set to bind to 127.0.0.1 (localhost), meaning that only local connections can be made.
The bind address can be set to 0.0.0.0 to listen on all interfaces.
bind-address = 0.0.0.0
You can also set the bind address to the IP of a specific interface, should you wish to limit where MySQL traffic comes from.
2. Ensure port 3306 is open inbound on firewall
Check for limitations on port 3306 inbound traffic on local/hardware firewalls.
3. MySQL User Configuration
Create new user:
You can either create a new user with the desired host or alter an existing user's host if necessary. However, creating a new entry is often the safest and most organized method.
Create a New Entry for the User:
CREATE USER 'example_user'@'203.0.113.1' IDENTIFIED BY 'user_password';
GRANT ALL PRIVILEGES ON database_name.* TO 'example_user'@'203.0.113.1';
FLUSH PRIVILEGES;
Alter existing user:
RENAME USER 'example_user'@'localhost' TO 'example_user'@'203.0.113.1';
FLUSH PRIVILEGES;
====================================================================================
No Comments