Need Assistance?

In only two hours, with an average response time of 15 minutes, our expert will have your problem sorted out.

Server Trouble?

For a single, all-inclusive fee, we guarantee the continuous reliability, safety, and blazing speed of your servers.

Remote MySQL Database setup for Magento2 domain

We can use a remote database server for Magento2 domains. In this, we use the Magento2 domain in one server and the database for this domain is configured in another one.

How to configure the Remote database server?

The remote MySQL database server must be installed with MySQL on it.

Then you need to configure the database and its user for the Magento2 domain.

For this, you have to log in to the Mysql prompt and create the DB.

mysql -u root -p
password : 

mysql > create database dbname;
mysql > GRANT ALL ON dbname.* TO dbuser@magento_server_ip_address IDENTIFIED BY 'password';

mysql > flush privileges;
mysql > GRANT ALL ON skynatsdb.* TO [email protected] IDENTIFIED BY 'Sky16R#k$kl';

Then try to connect this created database from the Magento2 server.

You have to log in to the Magento2 server first and then enter the below command to connect to the remote database server that we have created in the previous step.

mysql -u dbuser -h database_serverip -p dbname

Eg: mysql -u skynatsdb -h 192.168.10.1 -p skynatsuser

If you can successfully connect to the remote database from your Magento server. You can now proceed with changing the configuration file (env.php) of the Magento 2 domain to load with the new remote database. You can change the current default db section in the env.php file with the remote DB details.

vim /var/www/user/app/etc/env.php
----------------------------------
'host' => '192.168.10.1'
'dbname' => 'skynatsdb'
'username' => 'skynats'
'password' => 'Sky16R#k$kl'

Now you can successfully access your Magento site with the Remote MySQL database server.

Nowadays handling Magento sites is a very complex and careful task for users, so it is important to set it up perfectly to handle the DB connection to the domain.

Our technical team with efficient experience in Magento Projects will help you to resolve any issue with your Magento domains.

Liked!! Share the post.

Get Support right now!

Start server management with our 24x7 monitoring and active support team

Can't get what you are looking for?

Available 24x7 for emergency support.