How to Setup a WordPress MySQL Database in the Cloud
Tags: mysql, wordpress, database, developer
Published: 2019-07-29 21:22:14

---
title: How to Setup a WordPress MySQL Database in the Cloud
published: true
description: ScaleGrid: Learn the best way to setup a cloud MySQL database for your WordPress website so you can query your data such as  posts, pages, images, user profiles
tags: MySQL, WordPress, Database, Developer,
canonical_url: https://scalegrid.io/blog/how-to-setup-a-wordpress-mysql-database-in-the-cloud/
---
<link rel="canonical" href="https://scalegrid.io/blog/how-to-setup-a-wordpress-mysql-database-in-the-cloud/" />

<a style="text-align: justify;" href="https://scalegrid.io/blog/how-to-setup-a-wordpress-mysql-database-in-the-cloud/"><img class="alignnone size-full wp-image-4457" style="padding-top: 20px;" src="https://scalegrid.io/blog/wp-content/uploads/2019/07/How-to-Setup-a-WordPress-MySQL-Database-in-the-Cloud-ScaleGrid-Blog.jpg" alt="How to Setup a WordPress MySQL Database in the Cloud- ScaleGrid Blog" width="100%" height="auto" /></a>
<p style="text-align: justify;">WordPress is the largest website builder platform in the world, supporting <a style="color: #2da964;" href="https://www.wpbeginner.com/beginners-guide/how-to-choose-the-best-website-builder/">over 34%</a> of all websites on the internet today. MySQL is a free open source relational database management system that is leveraged across a majority of WordPress sites, and allows you to query your data such as posts, pages, images, user profiles, and more. As any WordPress developer knows, each installation requires a database in the backend, and MySQL is the database of choice for storing and retrieving your WordPress data.</p>
<p style="text-align: justify;">In order for your WordPress website to be able to access, store and retrieve the data in your MySQL database, it needs to be hosted online through a cloud computing service. ScaleGrid offers a convenient way to setup and configure <a style="color: #2da964;" title="MySQL Hosting" href="https://scalegrid.io/mysql.html" target="_blank">MySQL hosting</a> for your <a style="color: #2da964;" href="https://wordpress.com/" target="_blank">WordPress</a> site. In this blog post, we’ll show you <a style="color: #2da964;" href="https://scalegrid.io/blog/how-to-setup-a-wordpress-mysql-database-in-the-cloud/">how to create your MySQL deployment</a> at ScaleGrid while setting up your new WordPress site, and how to migrate to a ScaleGrid MySQL deployment for your existing WordPress deployment.</p>

<h2 style="text-align: justify; padding-top:10px;">Advantages of Using ScaleGrid MySQL Hosting for Your WordPress</h2>
<p style="text-align: justify;">Managing a database is hard, as it needs continuous updating, tuning, and monitoring to ensure the performance of your website. Fortunately, there are fully managed and hosted solutions like ScaleGrid’s MySQL-as-a-Service plans which take care of all your MySQL maintenance so you can focus on developing your websites and applications. Here are some of the ways ScaleGrid can help you improve your production WordPress setup:</p>

<ol>
	<li>
<h3>Platform and configuration of choice</h3>
<p style="text-align: justify;">Host <a style="color: #2da964;" href="https://scalegrid.io/mysql/aws.html">MySQL on AWS</a>, or <a style="color: #2da964;" href="https://scalegrid.io/mysql/azure.html">MySQL on Azure</a> with configurable instance sizes through the top two cloud providers in the world. We help you configure your MySQL deployment to optimize your performance based on the size of your databases.</p>
</li>
	<li>
<h3>High Availability</h3>
<p style="text-align: justify;">Make sure your website doesn’t go down with a server or datacenter crash by configuring a master-slave setup for high availability. Distribute your MySQL data across different datacenter regions, so if one goes down, you can automatically failover to the replica to stay online.</p>
</li>
	<li>
<h3>Automated Backups</h3>
<p style="text-align: justify;">Backups are copies of your data that are archived so you can access and restore them in case of a data loss event. This is a tedious process that needs to be performed regularly, but with ScaleGrid, you can automate a schedule to backup your systems as frequently as you like, and customize how long you want to keep your backups around.</p>
</li>
	<li>
<h3>Monitoring &amp; Alerts</h3>
<p style="text-align: justify;">Keep an eye on your database performance with advanced monitoring tools and query analysis for your database workload.</p>
</li>
	<li>
<h3>Scale On-Demand</h3>
<p style="text-align: justify;">As your data size grows, you will need to scale up your MySQL deployments to ensure your performance does not suffer due to a lack in capacity. This is again a tedious process that usually involves some downtime, but at ScaleGrid, you can scale up to a larger instance size in one click with zero downtime for a master-slave deployment.</p>
</li>
	<li>
<h3>Unlimited Databases</h3>
<p style="text-align: justify;">Create and deploy an unlimited number of MySQL databases through one single cluster at ScaleGrid, and easily create new database users with custom role privileges in a few simple clicks.</p>
</li>
</ol>


<h2 style="text-align: justify; padding-top:10px;">How to Create a MySQL Deployment at ScaleGrid</h2>
<ol>
	<li style="text-align: justify;">Sign up for a <a style="color: #2da964;" href="https://console.scalegrid.io/users/register">free 30-day trial</a> on the ScaleGrid console.</li>
	<li style="text-align: justify;">Create a new MySQL deployment in a few easy steps. Make sure to create it in a region that matches your WordPress deployment region. We support two different MySQL DBaaS plans on both AWS and Azure.
<ul>
<ul>
	<li style="text-align: justify;"><a style="color: #2da964;" href="https://help.scalegrid.io/docs/mysql-new-cluster-dedicated-hosting">Dedicated MySQL Deployment</a> - Host through your ScaleGrid account.</li>
	<li style="text-align: justify;"><a style="color: #2da964;" href="https://help.scalegrid.io/docs/mysql-new-cluster-bring-your-own-cloud">BYOC MySQL Deployment</a> - Host through your own cloud account.</li>
</ul>
</ul>
<a style="text-align: justify;" href="https://scalegrid.io/blog/wp-content/uploads/2019/07/create-2.png"><img class="alignnone size-full wp-image-4457" style="padding-top: 20px;" src="https://scalegrid.io/blog/wp-content/uploads/2019/07/create-2.png" alt="Create a New MySQL Deployment with Dedicated Hosting- ScaleGrid DBaaS" width="100%" height="auto" /></a></li>
	<li><b>Customize Your Plan</b><p>Enter a name for your new MySQL cluster, and select the same cloud region you are using for your WordPress hosting site (or the closest available one) for the best deployment performance. Next, select the VM size, ranging from Micro at 10GB of storage up to X4XLarge at 700GB of storage, and then your MySQL version and storage engine.</p></li>
	<li><b>Replication</b><p>Next, you can enable a master-slave configuration to ensure high availability for your MySQL database. This means, if one of your servers goes down, we will automatically failover your primary server to a healthy and available region. By default, you can use either a 2+1 configuration (master-slave-quorum) or a 3-node setup (master-slave-slave) with either semisynchronous or asynchronous replication and customize the regions to use for your secondary nodes.</p></li>
	<li><b>Advanced Security</b><p>In this step, you have an option to enable SSL for your MySQL deployment to secure connections between WordPress and MySQL. We recommend enabling SSL for every production deployment. You can also enable disk encryption to further protect your deployment from unauthorized access.</p></li>
	<li><b>Firewall Rules</b><p>In order for your WordPress server to be able to connect with your MySQL server, you must open up access by whitelisting this IP under your clusters firewall rules. Find your WordPress servers IP address in your WordPress account under the My Sites tab &gt; Network Admin &gt; WP Engine &gt; General Settings, then add it here to the IP whitelist. You can also learn more in our <a style="color: #2da964;" href="https://help.scalegrid.io/docs/mysql-firewalls">MySQL Firewalls</a> documentation.</p></li>
	<li><b>Summary &amp; Create</b><p>Review your MySQL configurations on the last Summary page, and click Create.</p></li>
</ol>
<h2 style="text-align: justify; padding-top:10px;">How to Setup Your MySQL Database &amp; Admin User for WordPress</h2>
<p style="text-align: justify;">While setting up your WordPress site, you will be asked to supply the hostname, database name and user credentials for your MySQL database. Here’s how you can set this up:</p>

<h3 style="text-align: justify; padding-top:10px;">Create a New MySQL Database</h3>
<ol>

	<li style="text-align: justify;">Go to your <a style="color: #2da964;" href="https://console.scalegrid.io/application/mysqlclusters">MySQL cluster list</a> page, and select your newly created cluster.</li>
	<li style="text-align: justify;">Select the ‘Databases’ tab, and click the green ‘New Database’ button.</li>
	<li style="text-align: justify;">In the ‘Create a new database’ window that pops up, simply enter a name for your database, for example, ‘wordpress_database’, and click ‘Create’:<a href="https://scalegrid.io/blog/wp-content/uploads/2019/07/Create-a-New-MySQL-Database-ScaleGrid-DBaaS.png"><img class="alignnone size-full wp-image-4502" style="padding-top: 20px;" src="https://scalegrid.io/blog/wp-content/uploads/2019/07/Create-a-New-MySQL-Database-ScaleGrid-DBaaS.png" alt="Create a New MySQL Database - ScaleGrid DBaaS" width="100%" height="auto" /></a></li>
</ol>


<h3 style="text-align: justify; padding-top:10px;">Create a New MySQL Database User</h3>
<ol>
	<li style="text-align: justify;">Select the ‘Users‘ tab on your MySQL cluster details page, and click the ‘New User’ button.</li>
	<li style="text-align: justify;">Select the new ‘wordpress_database’ that you just created from the dropdown field as the database for this user.</li>
	<li style="text-align: justify;">In the ‘New User’ window that comes up, enter a name and password for the new user, for example, ‘wpuser’.</li>
	<li style="text-align: justify;">Lastly, select ‘Read-Write’ as the ‘Role’ for this new user:
<a href="https://scalegrid.io/blog/wp-content/uploads/2019/07/new-user-2.png"><img class="alignnone size-full wp-image-4455" style="padding: 15px 0px;" src="https://scalegrid.io/blog/wp-content/uploads/2019/07/new-user-2.png" alt="new-user" width="100%" height="auto" /></a></li>


	<li style="text-align: justify;">Click ‘Create’ and your new user will be created! Make note of your database name, username, and password which you’ll need for your WordPress installation.</li>
</ol>
<h3 style="text-align: justify; padding-top:10px;">Find Your MySQL Hostname</h3>
<ol>
	<li>Go to your MySQL Cluster Details page and select the ‘Overview’ tab.</li>
	<li>Find the <a style="color: #2da964;" href="https://help.scalegrid.io/docs/mysql-command-line-syntax">Command Line Syntax</a> section at the bottom of the page to see the command that can be used to connect your MySQL deployment through MySQL client:<a href="https://scalegrid.io/blog/wp-content/uploads/2019/07/cmd-line-mysql-2.png"><img class="alignnone size-full wp-image-4458" style="padding-top: 15px;" src="https://scalegrid.io/blog/wp-content/uploads/2019/07/cmd-line-mysql-2.png" alt="cmd-line-mysql" width="100%" height="auto" /></a></li>

	<li>The server name following the ‘-h’ option is the hostname of your MySQL deployment, and in this particular case, it is ‘SG-help-1-master.devservers.scalegrid.io’.</li>
</ol>
<h2 style="text-align: justify; padding-top:10px;">Test Connectivity Between Your WordPress Site &amp; MySQL Server</h2>
<p style="text-align: justify;">Before you begin configuring your WordPress installation, we recommend checking the connectivity between your WordPress server and MySQL deployment. In order to check this, you will need a MySQL client on your server. Follow the instructions <a style="color: #2da964;" href="https://help.scalegrid.io/docs/mysql-command-line-syntax">here</a> to download and install and MySQL client if you dont already have one installed. Execute the following from the command line of your WordPress server and make sure you are able to connect:</p>

<pre>mysql -u wpuser -h SG-help-1-master.devservers.scalegrid.io -p<mark>&lt;Your Password&gt;</mark></pre>
<p style="text-align: justify;">If you’ve enabled SSL for your MySQL server, make sure that you see the ‘Cipher in use’ output for the SSL field as shown below:</p>

<pre>mysql&gt; status;

--------------

mysql  Ver 14.14 Distrib 5.7.15, for Win64 (x86_64)

Connection id:          79854

Current database:

Current user:           wpuser@xxxx

<mark>SSL:                    Cipher in use is DHE-RSA-AES256-SHA</mark>

Using delimiter:        ;

Server version:         5.7.21-log MySQL Community Server (GPL)

Protocol version:       10

--------------
</pre>

<h2 style="text-align: justify; padding-top:10px;">Configuring Your WordPress Installation to Use MySQL at ScaleGrid</h2>
<p style="text-align: justify;">During your WordPress installation, you will be asked to specify your MySQL database details. Now that you’ve created a new MySQL deployment, database, user, and found your hostname, you can enter these details here to connect:</p>
<p style="text-align: justify;"><a href="https://scalegrid.io/blog/wp-content/uploads/2019/07/wp-install-2.png"><img class="alignnone size-full wp-image-4459" src="https://scalegrid.io/blog/wp-content/uploads/2019/07/wp-install-2.png" alt="WordPress Installation Using ScaleGrid MySQL Database Host" width="100%" height="auto" /></a></p>
<p style="text-align: justify;">Once you submit, your WordPress installation should go through and be able to connect with your MySQL deployment hosted on ScaleGrid.</p>

<h2 style="text-align: justify; padding-top:10px;">Additional Step For SSL-Enabled MySQL Deployments</h2>
<p style="text-align: justify;">If you have enabled SSL for your MySQL deployment, then your WordPress installation requires an additional setting that cannot be specified through the UI above. In such cases, before installing WordPress, you will have to edit a file called wp-config-sample.php and save it as wp-config.php.</p>
<p style="text-align: justify;">You can follow detailed instructions here on <a style="color: #2da964;" href="https://codex.wordpress.org/Editing_wp-config.php">editing your wp-config.php file</a>. The sample below shows the MySQL section in the wp-config.php file, and the last line in this section indicates that MySQL has been configured with SSL:</p>
<p style="text-align: justify;"><a href="https://scalegrid.io/blog/wp-content/uploads/2019/07/wp-configure-2.png"><img class="alignnone size-full wp-image-4460" src="https://scalegrid.io/blog/wp-content/uploads/2019/07/wp-configure-2.png" alt="WordPress Configuration for SSL-Enabled MySQL Deployments - Edit wp-config File" width="100%" height="auto" /></a></p>
<p style="text-align: justify;">Once you complete the installation, you will see that your WordPress site is up and running using ScaleGrid’s MySQL hosting as its database!</p>
<p style="text-align: justify;padding-bottom:20px;">In the next part, I will talk about migrating from your existing database to ScaleGrid’s MySQL hosting for your existing WordPress site. Stay tuned!</p>