Support Online
Skip to main content

Improving Site Performance with MySQL Remote Database Installation

Keyword: MySQL remote database installation
Meta Description: Improve site performance by configuring the MySQL database on a remote server. SSL connection and secure configuration guide.

As your site grows, database management and web server performance become critical. In this guide, you will learn how to move your MySQL database from one server to another remote database server and the necessary steps to increase performance in the process.

What Will You Learn in This Guide?

  • Opening MySQL to remote connections.
  • Establishing a secure SSL connection between web and database servers.
  • Connecting WordPress to the remote database.

1. Step: Preparing MySQL for Remote Connections

Note that MySQL only accepts local connections by default. To enable remote connections, edit the mysqld.cnf file as follows:

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

  • Find the bind-address line in the file and change it as follows:

bind-address = db_server_ip

  • Then add this line to force connection via SSL:

require_secure_transport = on

  • Generate SSL certificates and restart MySQL service:

sudo mysql_ssl_rsa_setup --uid=mysql
sudo systemctl restart mysql

2. Step: Creating a Remote Access Authorized User

  • Create a user on the database server that can only access from the web server's IP address, instead of the root user:

CREATE DATABASE wordpress;
CREATE USER 'uzak_kullanici'@'web_sunucu_ip' IDENTIFIED BY 'guclu_sifre';
GRANT ALL PRIVILEGES ON wordpress.* TO 'uzak_kullanici'@'web_sunucu_ip';
FLUSH PRIVILEGES;
  • This user can only connect to the database from the web server.

3. Step: Testing the Connection on the Web Server

  • Switch to the web server and test connecting to the remote database by installing the MySQL client:

sudo apt update && sudo apt install mysql-client
mysql -u uzak_kullanici -h veritabani_sunucu_ip -p
  • Once connected, confirm that you have access to the database.

4. Step: Connecting WordPress to Remote Database

  • To connect WordPress to the remote database, update the wp-config.php file as follows:

define('DB_NAME', 'wordpress');
define('DB_USER', 'uzak_kullanici');
define('DB_PASSWORD', 'guclu_sifre');
define('DB_HOST', 'veritabani_sunucu_ip');
define('MYSQL_CLIENT_FLAGS', MYSQLI_CLIENT_SSL);
  • These settings allow WordPress to connect securely to the remote database via SSL.

Frequently Asked Questions (FAQ)

1. Does using a remote database slow down the site? If the servers are in the same data center, the delay is in milliseconds and overall performance increases.

2. I'm getting a connection error (Connection Refused), what should I do? MySQL port (3306) must be open in the firewall. You can open it with the following command:


sudo ufw allow mysql

3. Should I use a private network? Yes, it is safer and faster to carry data traffic over a private network.

4. Is it mandatory to use SSL? Yes, it is mandatory to use SSL for the security of data, especially if you are connecting via public IP.

Result

Improve site performance by configuring the MySQL database on the remote server. Ensure security with SSL connections.

To professionally optimize database management, you can try the high-performance servers on the GenixNode platform now!