Support Online
Skip to main content

Remote MySQL Installation on Ubuntu 16.04

In this guide, you will learn how to setup a remote MySQL database for projects using WordPress.
The goal is to reduce web server load and secure the database connection with SSL/TLS.

What Will You Learn in This Guide?

  • Logic of separating web and database server
  • Opening MySQL for remote access
  • Encrypt database connection with SSL/TLS
  • How to run WordPress with remote MySQL

This structure provides performance and scalability in growing projects.


Requirements

  • 2 Ubuntu 16.04 Cloud Servers
    • One Web Server (Nginx + PHP installed)
    • One Database Server
  • On both servers:
    • sudo authorized user
    • UFW firewall active

1. Step: Installing MySQL on Database Server

  1. We install MySQL only on the database server.
sudo apt-get update
sudo apt-get install mysql-server
  • This command installs the MySQL server and asks you to create a root password.

  • Check that the MySQL service is running:

systemctl status mysql

2. Step: MySQL Basic Security Settings

  1. Run the security script to close the default exploits.

mysql_secure_installation
  • It is recommended that you answer Yes (y) to all questions.

3. Step: Remote Access and SSL Configuration

  1. Open the MySQL configuration file:

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

  1. Under mysqld, make these settings:

bind-address = db_sunucu_ip
require_secure_transport = on
  • These settings enable MySQL to accept remote and encrypted connections.

  1. Generate SSL keys:

sudo mysql_ssl_rsa_setup --uid=mysql

  1. Restart MySQL:

sudo systemctl restart mysql

4. Step: Firewall Setting

  1. Open the MySQL port:

sudo ufw allow mysql

  1. Verify that MySQL is listening:

sudo netstat -plunt | grep mysqld

5. Step: Creating WordPress Database and User

  1. Log in to MySQL:

mysql -u root -p

  1. Create the database:

CREATE DATABASE genixnode_wp;

  1. Create local user:

CREATE USER 'genix_user'@'localhost' IDENTIFIED BY 'guclu_sifre';
GRANT ALL PRIVILEGES ON genixnode_wp.* TO 'genix_user'@'localhost';

  1. Create remote user for web server:

CREATE USER 'genix_user'@'web_sunucu_ip' IDENTIFIED BY 'guclu_sifre';
GRANT ALL PRIVILEGES ON genixnode_wp.* TO 'genix_user'@'web_sunucu_ip';

  1. Save authorizations:

FLUSH PRIVILEGES;
exit;

6. Step: Testing the Remote Connection

  1. Install MySQL client on the web server:

sudo apt-get install mysql-client

  1. Test the connection:

mysql -u genix_user -h db_sunucu_ip -p

  1. Verify that SSL is used:

status;
  • If you see the SSL: line, everything is OK.

7. Step 1: Configure WordPress with Remote MySQL

  1. Download WordPress:

curl -O https://wordpress.org/latest.tar.gz
tar xzvf latest.tar.gz

  1. Create the configuration file:

cp wordpress/wp-config-sample.php wordpress/wp-config.php

  1. Get security keys:

curl -s https://api.wordpress.org/secret-key/1.1/salt/

  1. Add it into wp-config.php and edit the database information:

define('DB_NAME', 'genixnode_wp');
define('DB_USER', 'genix_user');
define('DB_PASSWORD', 'guclu_sifre');
define('DB_HOST', 'db_sunucu_ip');
define('MYSQL_CLIENT_FLAGS', MYSQLI_CLIENT_SSL);

  1. Move the files to the web directory:

sudo cp -a wordpress/* /var/www/html
sudo chown -R www-data:www-data /var/www/html

8. Step: Completing the Setup Via the Web Interface

  1. Navigate to your domain in the browser.
  2. Complete the WordPress installation wizard.

Frequently Asked Questions (FAQ)

1. Why does remote MySQL gain performance? Web and database load are split on separate servers.

2. Can I use it without SSL? Not recommended. Network traffic becomes open.

3. Should I use private or public IP? If in the same data center, choose private IP.

4. Does this build work in new Ubuntu versions? Yes, the logic is the same in all LTS versions.

Result

With this structure, your WordPress site becomes faster, more secure and scalable. It creates a solid foundation for high-traffic projects.

👉 Create two Cloud Servers on the GenixNode platform immediately and take this architecture live.