Make your MySQL database connection accessible remotely

Eby Sofyan
2 min readMay 25, 2019
Source : https://i.stack.imgur.com/E16Dn.jpg

When you have a server and already installed MySQL, you will find the fastest way to create new database, alter some table, and create or alter your record. Imagine if you access your database from terminal, more complex right?

Let’s count how many step if you access your database from your terminal

Step 1. Login to your server using sshssh user@ip_address

Step 2. Login to your database using mysql -u root -p

Step 3. Do everything you want

But the most annoying thing is, you should know or memorize every database command 😆

What? That’s simple, just use phpmyadmin and it’s clear.

How if i doesn’t like phpmyadmin ? 😆 😆 😆

Up to you . . .

Okay, this article intended for people who doesn’t like phpmyadmin 🕺 🕺 🕺

On my machine, already installed mysql-workbench or you can use another tools for mysql. MySQL by default doesn’t allow to access remotely until you changes the world . . .

How to do this? let’s follow several step

Step 1. Login to your mysql using mysql-cli

mysql -u root -p

Step 2. Follow below command

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'your-password' WITH GRANT OPTION;FLUSH PRIVILEGES;

Step 3. Change mysql configmy.cnf . Find this line bind-address and change itHow simple it is?

from

bind-address = 127.0.0.1

to

bind-address = 0.0.0.0

Step 4. This is the last step, restart your mysql service from your machine

sudo service mysql restart

Wowwww . . . . How simple it is? !!!! 😨 😨 😨 😨

That’s it all. If you find missing way, don’t hesitate to make a comment and clap for this article if it use full. Thank you.

--

--

Eby Sofyan

Software developer with almost 3 years experience especially in Backend and Android Developmnet. Using Django and Kotlin as weapon.