Here is a Step by Step Guide on How To Setup a Separate MySQL Database Server on Rackspace Cloud Server and Connect From FTP Server Easily. For scalability on cloud computing platform, we need to distribute the load. To run WordPress like CMS, it is almost mandatory to separate the application server from FTP server. In our case, the application server is MySQL Database Server; MySQL by default is not ready to accept connection requests even within the same network. First, we will explain the logical approach for running a separate MySQL Database setup on Rackspace Cloud and Secondly we will provide you the needed commands. We need only the ServiceNet IP address (= Private Network) of both the Server Instances. There is no bandwidth charge for connecting to the server. Possibly it is better to judge your need of amount of RAM before going for this setup. An one GB PVHVM for MySQL Database instance is quite fine for most of the WordPress websites with medium traffic load. Keep in mind – you need to tweak the MySQL instance later. Otherwise MySQL will use a limited small amount of RAM!
Principle of Running a Separate MySQL Database Setup on Rackspace Cloud Server
The server which will be used as MySQL database server, name it accordingly to avoid confusion. You can change the default welcome message on SSH too. Often the things go wrong only for getting confused with more than 3-4 servers!
By default, MySQL Server keeps the
localhost. We need to change it to this database server’s ServiceNet IP address (= Private Network). Understand it – instead of localhost or 127.x.x.x.x we will use the specific IP address. We could use the public IP address, but we – (i) want to reduce our bill (ii) disallow anyone outside Rackspace to connect to our MySQL Server.
Second thing is related to creation of database – we will run the SQL queries to create database, give permission using the FTP server’s ServiceNet IP address (= Private Network).
Make it clear. There is no other big deal.
Commands For Running a Separate MySQL Database Setup on Rackspace Cloud Server
After successfully spinning up the two servers (FTP and MySQL server), ssh to the server which you’ll run MySQL only. Run these commands :
apt-get install mysql-server
# keep note of the root password
Now run this command :
After this step, on earlier versions, we used to run :
Now you will get the needed commands as output after running
mysql_install_db command. Just copy paste and run it or run the above one. You will need to enter the MySQL root password that you provided above. Afterwards, it will ask questions. To all of these questions except changing the password and allowing remote connection, you should just hit ENTER/RETURN key to select the default options which will remove some test databases and secure it.
Now open the config file :
Search the word
bind-address with ^ + W (on Mac, keyboard mapping can differ on other OS) and change it to this MySQL Server’s ServiceNet IP address from default localhost value :
bind-address = localhost
bind-address = your_service_net_IP
Save it using ^ + O, exit with ^ + X. Restart MySQL :
service mysql restart
# check status
service mysql status
Forget this server’s ServiceNet IP address! Now your work is with only the FTP server’s ServiceNet IP address. If you have multiple FTP servers, you have to repeat the steps. Examples are given with easy to guess words, change them :
# login to mysql as root
mysql -u root -p
# change the database name from wordpress to difficult one
CREATE DATABASE wordpress;
# change the wordpressuser, service_net_IP (=FTP server's IP), password
CREATE USER 'wordpressuser'@'service_net_IP' IDENTIFIED BY 'password';
# how much you want to grant access?
GRANT SELECT,DELETE,INSERT,UPDATE ON wordpress.* TO 'wordpressuser'@'service_net_IP';
# normally we give all
GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpressuser'@'service_net_IP';
Exit the SSH session. SSH to your FTP server, install the web server software you want (Apache, nginx…) and only install MySQL client :
apt-get install mysql-client
You can login from this server to that database server with this command :
mysql -u wordpressuser -h database_server_service_net_IP -p
There should be no error. You’ll proceed to install WordPress or whatever, use database server’s ServiceNet IP to connect (instead of localhost as database name). After WordPress get installed, you can go to Rackspace Cloud Control Panel and switch off Public IP address of the Database Server. First, we will never need it as we can access MySQL from the allowed server, Secondly, you can add public IP at anytime (or loadbalancer) to SSH on need, Thirdly, it increases the security and finally – the number of white listed IP address is limited in the whole World, we should release which we will not need.