AWS EC2 - Enable remote access on mysql
I think most of us know that enable remote access, need to create a new user with
But in EC2, there are some security config need to be done.
Go to your AWS console, select the instance where you host your database (MySQL).
Then select the security group
Make sure you add a rule in the In bound there, for MySQL, and set the IP to
Edit the file
/etc/mysql/my.cnf, and change the binding address to
(EDIT: 2019-04-04, you may also update the file
, for newer version of MySQL. Thanks for Dawood pointing out.)
bind-address = 0.0.0.0
then restart mysql server
$ sudo /etc/init.d/mysql restart
CREATE USER 'foo'@'%' IDENTIFIED BY 'your-awesome-pass';
NOTE: bare in mind that
'foo'@'%' are consider as different user, you may have 2 different passwords for each of them