- 62 Views
- 08/12/2025
How to Create a Remote Root User in MySQL 5.7
A complete guide on how to enable remote access for the root user or create a new remote user in MySQL 5.7. This tutorial covers granting privileges, updating the bind-address configuration, opening port 3306, and testing remote connections safely. Ideal for anyone who needs MySQL access from external applications or management tools.
Remote access to MySQL is disabled by default for security reasons. If you need to connect to your MySQL 5.7 server from an external machine—using tools like MySQL Workbench, DBeaver, or another service—here is a full step-by-step guide.
1. Log in to MySQL
Start by accessing your database from the server terminal:
2. Check whether the root user already allows remote access
Run:
If you see Host = localhost, it means the root account can only log in locally.
3. Allow remote access for the root user
Option 1: Modify the existing root user (not recommended for production)
SET Host='%'
WHERE User='root' AND Host='localhost';
FLUSH PRIVILEGES;
Option 2: Create a dedicated remote user (recommended)
This option is safer and follows best practices.
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;
4. Update MySQL configuration to listen on all interfaces
Edit the MySQL configuration file:
Find the line:
Change it to:
Restart MySQL:
5. Open port 3306 on your firewall
UFW (Ubuntu)
Firewalld (CentOS/RHEL)
sudo firewall-cmd --reload
Security recommendations
Avoid enabling remote access for the root account in production.
Use strong passwords.
Restrict external access to specific IP addresses, for example:
GRANT ALL PRIVILEGES ON *.* TO 'root'@'123.456.789.10';
Consider using SSH tunnels or VPN for safer connections.
Thanks for visit my website
