Update: Feb 2017
Here are the COMPLETE STEPS for remote access of MySQL (deployed
on Amazon EC2):-
1. Add MySQL to inbound rules.
Go to security group of your ec2 instance -> edit inbound rules -> add new rule -> choose MySQL/Aurora
and source to Anywhere
.
2. Add bind-address = 0.0.0.0 to my.cnf
In instance console:
sudo vi /etc/mysql/my.cnf
this will open vi editor.
in my.cnf file, after [mysqld]
add new line and write this:
bind-address = 0.0.0.0
Save file by entering :wq
(enter)
now restart MySQL:
sudo /etc/init.d/mysqld restart
3. Create a remote user and grant privileges.
login to MySQL:
mysql -u root -p mysql
(enter password after this)
Now write following commands:
CREATE USER 'jerry'@'localhost' IDENTIFIED BY 'jerrypassword';
CREATE USER 'jerry'@'%' IDENTIFIED BY 'jerrypassword';
GRANT ALL PRIVILEGES ON *.* to jerry@localhost IDENTIFIED BY 'jerrypassword' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* to jerry@'%' IDENTIFIED BY 'jerrypassword' WITH GRANT OPTION;
FLUSH PRIVILEGES;
EXIT;
After this, MySQL dB can be remotely accessed by entering public dns/ip of your instance as MySQL Host Address, username as jerry and password as jerrypassword. (Port is set to default at 3306)