Granting mysql access from remote is not secure, so it’s not recommendable but sometimes we need to do it. Here’s how to do.
- Login to mysql with root and create user with remote connect.
GRANT ALL PRIVILEGES ON remote_db.* TO 'remote_user'@'%' IDENTIFIED BY 'passwordhere'; FLUSH PRIVILEGES;
- We need to allow remote connection from mysql configuration. mysql.cnf or mysqld.cnf files locations are differ but in my case, it is located in /etc/mysql/mysql.conf.d/ folder.
vi /etc/mysql/mysql.conf.d/mysqld.cnf
And comment out below line.
#bind-address = 127.0.0.1
After that mysql restart desired.
service mysql restart
- Now if you have any firewall or network security, allow the port. In my case, I needed to allow 3306 port in AWS inbound rule.
- Try to connect from remote.
mysql -u {username} -p -h {ip address}
mysql remote connection
Facebook Comments