New WordPress sites created with Nodalio have the processing services and MySQL database running on the same server.
In order to scale, its recommended to separate the processing and the database to allow more headroom for each service to grow and utilise additional server resources.
The separation is especially recommended for large website and e-commerce applications, with a large number of un-cached dynamic pages/requests where the site processing may utilise all the available server resources. In cases where most of the system resources are being used for site processing, MySQL server may function slower, resulting in a generally slower user experience due to database queries taking much longer to retrieve information.
To begin with the separation process, make sure you have a blank server with Nodalio installed (see Your First WordPress VPS for instructions on how to install a new server with Nodalio).
You may create a new database in the following methods:
- Using the databaseadd shortcode via the terminal in the Nodalio Dashboard.
- Using the Nodalio Sites Manager, create a new database in the databases tab.
After creating the database, make sure to save the database username and password sent to the server owner email.
Next, we need to create a database export (If needed) and import it to the new database server. Follow the steps to export your database to a separate server:
1. Go to the Nodalio Dashboard and open the terminal. Navigate to your site using the “cd” Linux command (this command allows you to move between folders on your server). Use the sites path configured for your server, or ” /var/www “ by default. To navigate to your site directly, use the following command:
2. Using wp-cli, create an export of the site database. The export will be accessible YOURSITE/site-export.sql, or you may download the database export with SFTP.
wp db export site-export.sql --allow-root
2. Access the Nodalio Sites Manager to create a new database which will be used on your new database server. Save the database name and user for future steps.
3. To import the exported database in the new database server. Using the Nodalio Dashboard, access the terminal (to download the backup and import it to the new database).
Download the database export to the database server run this command from the terminal:
wget -q YOURSITE/site-export.sql
4. Import the exported database in the new server using the Nodalio Dashboard.
mysql -u nodalio6414 -p nodalio6414 < site-export.sql
nodalio6414 is the database name and user created in step 2. Replace the name to the one you received earlier. Replace ” site-export.sql ” if you’ve used a different file name when exporting the database.
5. The last step is to change the database connection on the site (processing) server. To change the database connection open the ” wp-config.php ” file in the live folder of your site.
Change the following defines:
DB_NAME – The name of the external database.
DB_USER – The name of the external database user.
DB_PASSWORD – The password of the external database user.
DB_HOST – The external database server IP.
Congratulations! Your site should now have a separated database and application server.