ItSolutionStuff.com

How to Allow Remote Access to Database on Digital Ocean Server?

By Hardik Savani β€’ May 1, 2024
Ubuntu

Hello Dev,

This definitive guide, we will show you allow remote access to mysql database ubuntu. let’s discuss about allow remote access to mysql database digitalocean. you can understand a concept of how to enable remote access to mysql server on ubuntu. step by step explain ubuntu mysql server allow remote access. Follow the below tutorial step of how to allow mysql remote access in ubuntu server.

Sometimes, we need to allow remote access to the MySQL database on the ubuntu server. I have a Digital Ocean Ubuntu server and I want to enable remote access to the MySQL server. I followed a few steps to allow remote access to MySQL database digital ocean server.

So, let's follow the below steps:

Step 1: Connect to SSH Server

Here, we will connect to my digital ocean server using the ssh command. right now i am adding my IP address like 111.111.111.23. let's run the below command:

ssh root@111.111.111.23

Step 2: Install MySQL Server

This is an optional step, if you haven't installed MySQL server then you need to run the following commands to install it.

sudo apt-get update && sudo apt-get install mysql-server -y

Step 3: Configure MySQL Server

Here, we will open mysqld.cnf config file and change value of bind-address to 0.0.0.0, so let's run below command and change value.

sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf

Now change bind-address to 0.0.0.0, so that it can be accessed by any remote server.

bind-address = 0.0.0.0

Step 4: Enable Firewall

Here, we will enable firewall port 3306 with restart mysql server.

sudo ufw enable && sudo ufw allow 3306

sudo systemctl restart mysql

sudo systemctl enable mysql

Step 5: Create MySQL User

Here, we will create mysql user demo with password. follow the below commands:

mysql -u root -p

SELECT User, Host, authentication_string FROM mysql.user;

CREATE USER 'demo'@'%' IDENTIFIED BY 'your-password';

GRANT ALL PRIVILEGES ON *.* TO 'demo'@'%' WITH GRANT OPTION;

FLUSH PRIVILEGES

Step 6: Connect Database Remotely

now, you are ready to connect remotely database. so let's check with following command:

mysql -udemo -p -h 111.111.111.23

You can also import database by following command:

mysql -udemo -p -h 111.111.111.23 name-of-your-database < name-of-your-database.sql

I hope it can help you...

Tags: Ubuntu
Hardik Savani

Hardik Savani

I'm a full-stack developer, entrepreneur, and founder of ItSolutionStuff.com. Passionate about PHP, Laravel, JavaScript, and helping developers grow.

πŸ“Ί Subscribe on YouTube

We Are Recommending You

β˜…

How to Check Apache Access & Error Log Files in Ubuntu Server?

Read Now β†’
β˜…

How to Whitelist/Allow IP Address in Apache Ubuntu?

Read Now β†’
β˜…

How to Restrict/Block IP Address in Apache Ubuntu?

Read Now β†’
β˜…

How to Install Laravel in Ubuntu Server?

Read Now β†’
β˜…

How to Set Up Password Authentication with Apache in Ubuntu?

Read Now β†’
β˜…

How to Install Composer in Ubuntu Server?

Read Now β†’
β˜…

How to Install Apache PHP MySQL and Phpmyadmin on Ubuntu?

Read Now β†’
β˜…

How to Change PHP Version in Ubuntu Server?

Read Now β†’
β˜…

How to Install Phpmyadmin in Ubuntu Server?

Read Now β†’
β˜…

How to Install MySQL in Ubuntu Server?

Read Now β†’
β˜…

How to Install PHP in Ubuntu Server?

Read Now β†’
β˜…

How to Install Apache Web Server on Ubuntu Server?

Read Now β†’
β˜…

How to Connect to a Remote Server using SSH on Ubuntu?

Read Now β†’