We recently had to create a mysql server on an Azure VM and give remote access to one database.
I followed the very good documentation here. The steps I had to follow were connecting via ssh
Then, to install mysql server
This automatically creates mysql service which makes sure that mysql is restarted when VM is rebooted
And then we have to secure this mysql installation. Running this command helps you set the values for common settings by asking you questions and recommending good options
After this log into mysql as root
To create a new MySQL user, run the following at the mysql> prompt
Create a database and give all privileges to mysqluser
Other options in this command are
For a complete list of options available you should consult MySQL Docs
To permit the user mysqluser to connect from any ip,
Notice that we used ‘%’ as a wild card for ip while ‘*’ for database/table names wildcard. For a remote user to connect with the correct privileges you need to have that user created in both the localhost and ‘%’ as in.
Exit the mysql shell
This is not all. We have to add the port where mysql is running (default is 3306) as an endpoint in azure management portal. We have to change the bind-address in mysql config that is located at /etc/mysql/my.cnf. As per this SO answer , you should edit that file and put this line for bind-address
Then mysql needs to be restarted. As per this answer
You should now be able to connect and access students table in testdatabase as mysqluser from anywhere in the world by providing the following params.