Hi, I wonder if we can host wordpress database (mysql) in an other server which is not the server storing the content (source code, uploads files, plugins, theme...) Will that make any performance and security improvement? Is there any service specialized in hosting only database? Thanks,
Yes, as long as the MySQL server allows the database to be accessed by external servers. When you set up WP, instead of "localhost", you'll put in the SQL server.
Thanks, what if I already installed wordpress before and want to move the database? There are still some concerns that I need your help
Yes, you can export the current database, then you will create a database on another server, then instead of "localhost" (in the config.php ) you will put the IP address of the server and then the config.php will connect
well this is not good idea unless your Wordpress source file and your database are in the same network... what I mean is if you host your database in different network and your source in different network there would be a lot of latency... as when someone access your site the source files have to access database across internet to put out the information and sometimes access this through internet is bad bad idea
You won't get any performance boosts from this, unless you're having a LOT of traffic, separate hosting/caching/sql-servers, and running each on a separate server within a fiber-cable-setup or at least GB-local network - there is NO real point in running this on separate servers, unless you're running this on a poorly configured shared-hosting server - then you might get a slight improvement by running the SQL on a separate server, but yet again, only if it's on a local node. Going through the Internet for this is NOT recommended. Also, remember that if you go through the Internet, this will be pulled from any traffic-charges (bandwidth) you have.
this only good if both web server and database server are in the same network or better in a private LAN configuration as it will have little ping time and secure (data are not transferred via internet connection)
Well in case you got plenty of visitors it's worth using a dedicated/vps just for your sql db, and separate http from db. And even more in future it will be better to use clusters for http and db.
As said by others , its not advisable to have them separately. One other reason is that , if the server that has the database fails or shuts down , then the website files will not be able to access the database & so your site will not display to the end user. Also bandwidth will be different for these 2 servers , which will also add pain when you have more visitors / traffic at any point in time. Last but not least , when you upgrade php versions & mysql versions , you have to do it on both the servers , which will be time consuming & cost you more money. So the best option would be to move onto a dedicated server hosting both the source files & database on the same server , this will be bit easier for you to update/manage the server in future. Hope this helps
// wp-config.php define ( 'DB_NAME', 'yourdbname' ); define ( 'DB_USER', 'yourusername' ); define ( 'DB_PASSWORD', 'yourpassword' ); define ( 'DB_HOST', '111.222.0.1' ); // IP address of the server where MySQL is running // make sure MySQL server will listen to the request from your WP server IP ! Code (markup):
No. Not necessarily. Same NETWORK. If you have a GB-connection between the file-server and the db-server, you're pretty good. If you have a 10GB connection, you're golden. If they're on different subnets, or different locations, or even worse, have no dedicated line between them, you're gonna have latency issues, packet drops and other problems.
Right, infact a separate mysql and webserver will improve speed and performance ,we have done such clustered solutions for few of our customers.
can you explain me why separate mysql and files server can improve ? if you have only 1 server but very powerful and with lots of RAM, wouldn't it be better ?
Depending on what you need, and how much load you put on both the webserver and/or DB-server, there is just so much you can do with one server, before the cost is becoming prohibitive. By dividing it up, you have separate servers doing the work only for what they host. 20000 user on your webserver? Not that big a problem. 20000 users using the database? Not a big problem. Having 40000 users on the same server, using both the webserver and the db-server might be harder - also, take note that these numbers are just arbitrarty numbers used to prove the point. Depending on your specific server-setup, the number might be lower, or it might be higher.
If you keep webserver and mysql access separate , may server process will be divide , and CPU usage of the server will also be divide in this case. A single server when handles all the process it will affect the performance.
Quite simply everything depends on the host's capability to establish a remote database connection. If it does, use the database's location IP address as the hostname.
The main reason to split up a web server and a database server is dedicated resources. Generally with php, you have a wide variety of settings that allow the setting to use a range of resources. With mysql, your my.cnf file allows you to set various configuration settings, and depending on your max "connections" settings, will use a range of RAM. By separating the two, you can set the database server to have a dedicated amount of RAM, CPU, and allow the web server to have its own set of resources. By having them on the same server, you increase the chances of one service monopolizing the resources and starving the other, which can lead to hangups or swapping since the servers are trying to load additional ram, and cannot find any. In bad scenarios, the server may start killing processes to free up resources (can sometimes be the mysql daemon). If you are running small wordpress or drupal website, then this not a big issue, and you should keep it on the same server. If you are running a beefy site, you may want to split up your configuration so that mysql is running on a ssd server, and your web server is running separately, with more space, on a hdd server. As most resources will be stored in ram, the gain in having your web service on ssd is not much, compared to mysql. And mysql will get a boost from the additional read/write that SSD affords, while keeping costs lower. Regardless, the OP asked if you could, and of course you can. My recommendation is to dump your database mysqldump [database] > [database].dump transfer it to the external mysql server, import it mysql [database] < [database].dump and then make sure that you create the mysql user on the external database, and set the ip/domain of the web server for host. You do not want to allow % (anyone) access. If you are familiar with it, lock down port 3306 to the web server, and then on the web server, run a test to verify that you can connect to the external database server mysql -u[user] -p -h[external database domain/ip] [database] I recommend doing this as you can spend quite a bit of time debugging why things are not working, when it may just simply be an invalid user configuration on the external database. If you are using cPanel, there is an option for external databases, so that you can allow access to a specific external domain. If you run into issues, open up a ticket with your hosting provider, as they may block external access to port 3306 (mysql) which could cause you a lot of time and frustration to debug.