{"id":1163,"date":"2015-02-25T20:43:10","date_gmt":"2015-02-26T02:43:10","guid":{"rendered":"http:\/\/www.threshold-zero.com\/cblog\/?p=1163"},"modified":"2015-02-25T20:43:10","modified_gmt":"2015-02-26T02:43:10","slug":"using-dreamhosts-vps-as-a-mysql-server","status":"publish","type":"post","link":"https:\/\/www.threshold-zero.com\/cblog\/2015\/02\/using-dreamhosts-vps-as-a-mysql-server\/","title":{"rendered":"Using Dreamhost&#8217;s VPS as a MySQL Server"},"content":{"rendered":"<p>[<em>Editor&#8217;s Note: Dreamhost no longer allows sudo access on their VPS servers, so the below is no longer possible. If you&#8217;re reading this, you might want to check out Amazon&#8217;s AWS. Nowhere near as user friendly as Dreamhost, but MUCH more powerful.<\/em>]<\/p>\n<p>I&#8217;ve been a happy customer of DreamHost for many years now &#8212; for $9.95 a month, I was able to get loads of diskspace and unlimited bandwidth, all from a great company that was staffed by great people who were very technically competent.<\/p>\n<p>It is &#8220;shared hosting,&#8221; however &#8212; that means you&#8217;re getting it that cheap because you&#8217;re sharing server CPU power, available RAM, etc, with many other people who are also getting a great deal. You&#8217;ll notice this in any WordPress sites you may run on Dreamhost&#8217;s shared hosting &#8212; there&#8217;s about a 7-10 second delay between when you navigate to your site and when your page actually loads, mostly because <em>your<\/em> server processes are waiting in line behind everyone else&#8217;s.<\/p>\n<p>So, Dreamhost does offer a &#8220;VPS&#8221; service &#8212; with this, you&#8217;re getting an absolute amount of RAM, CPU power, etc, that will only be used for your sites. It&#8217;s a tiny bit more expensive, at $14.95 or so a month, but it&#8217;s worth every penny.<\/p>\n<p>If you&#8217;ve run WordPress installations on a Dreamhost site, though, you know that your mysql databases are on a seperate server entirely, and that may slow things down as well. Even if you move your WordPress installs to a VPS, your mysql databases will still be on shared hosting. DreamHost offers a &#8220;MySQL VPS,&#8221; but it costs another $15 a month (minimum), and you have no control over it at all.<\/p>\n<p>A better solution would be to run your own MySQL server on DreamHost&#8217;s main VPS, since they give you root command-line access. There are a few hiccups in this process (some put there by DreamHost itself), but otherwise you should be able to do it.<\/p>\n<ol>\n<li>First, create an admin user for your VPS that has sudo abilities, and log into your VPS with that through <strong>ssh<\/strong>.<\/li>\n<li>Second, you have to tweak <strong>apt<\/strong> so you can even install the <strong>mysql-server<\/strong> package. It appears as if part of installing packages through apt involves temporarily storing files in <strong>\/tmp<\/strong> and then running them from there.Unfortunately, the \/tmp directory is mounted on DreamHost&#8217;s VPS servers with the <strong>noexec<\/strong> option, which means that you can&#8217;t run files that are present in that directory. That basically prevents you from installing the mysql-server package until you tweak apt to temporarily stage files in <strong>\/var\/tmp<\/strong> instead. Do this by:Creating a file called <strong>apt.conf <\/strong> in the <strong>\/etc\/apt\/<\/strong> directory, and edit it so the contents are the following:\n<pre>APT::ExtractTemplates::TempDir \"\/var\/tmp\";<\/pre>\n<\/li>\n<li>Then, install the mysql-server package:\n<pre>sudo apt-get install mysql-server;\n<\/pre>\n<p>(When it asks to set a root password, make sure and set one.)<\/li>\n<li>Now, edit the file <strong>\/etc\/mysql\/my.cnf<\/strong> and set the following options:\n<pre>bind-address=psXXXXX.dreamhostps.com<\/pre>\n<p>(Replace psXXXXX with the name of your dreamhost VPS.)<\/li>\n<li>Restart your mysql service:\n<pre>sudo service mysql restart<\/pre>\n<\/li>\n<\/ol>\n<p>At this point, you should be able to log in to your new mysql server:<\/p>\n<pre>mysql -u root -p<\/pre>\n<p>and then perform what SQL functions you need to.<\/p>\n<p>A great thing to do is to install phpmyadmin using the tutorial here: <strong>http:\/\/wiki.phpmyadmin.net\/pma\/Quick_Install<\/strong><\/p>\n<p>First you&#8217;ll want to create a user (that isn&#8217;t your root user) to log into phpmyadmin:<\/p>\n<pre>mysql&gt; CREATE USER \u00c2\u2018newusr\u00c2\u2019@\u00c2\u2019%\u00c2\u2019 IDENTIFIED BY \u00c2\u2018your_password';\nmysql&gt; GRANT ALL PRIVILEGES ON *.* TO \u00c2\u2018newusr\u00c2\u2019@\u00c2\u2019%\u00c2\u2019 WITH GRANT OPTION;<\/pre>\n<p>At this point, you can sync your old databases to your new mysql server using the built-in sync tool that&#8217;s in DreamHost&#8217;s installations of phpmyadmin.\u00c2\u00a0 Then, just edit the <strong>wp-config.php<\/strong> file in the folder of your WordPress installations, and change the line that says the following to your DreamHost VPS:<\/p>\n<pre>define('DB_HOST', 'psXXXXXX.dreamhostps.com');<\/pre>\n<p>Sources:<\/p>\n<p>http:\/\/howtogetitworking.com\/2011\/06\/28\/installing-mysqld-dreamhost-vps\/<\/p>\n<p>https:\/\/bugs.launchpad.net\/ubuntu\/+source\/debconf\/+bug\/90085<\/p>\n<p>http:\/\/serverfault.com\/questions\/72356\/how-useful-is-mounting-tmp-noexec<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>[Editor&#8217;s Note: Dreamhost no longer allows sudo access on their VPS servers, so the below is no longer possible. If you&#8217;re reading this, you might want to check out Amazon&#8217;s AWS. Nowhere near as user friendly as Dreamhost, but MUCH more powerful.] I&#8217;ve been a happy customer of DreamHost for many years now &#8212; for [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[112,11,18,15,31],"tags":[],"class_list":["post-1163","post","type-post","status-publish","format-standard","hentry","category-hacking","category-linux","category-programming","category-science-and-technology","category-ubuntu"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p2ZUZG-iL","_links":{"self":[{"href":"https:\/\/www.threshold-zero.com\/cblog\/wp-json\/wp\/v2\/posts\/1163","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.threshold-zero.com\/cblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.threshold-zero.com\/cblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.threshold-zero.com\/cblog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.threshold-zero.com\/cblog\/wp-json\/wp\/v2\/comments?post=1163"}],"version-history":[{"count":0,"href":"https:\/\/www.threshold-zero.com\/cblog\/wp-json\/wp\/v2\/posts\/1163\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.threshold-zero.com\/cblog\/wp-json\/wp\/v2\/media?parent=1163"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.threshold-zero.com\/cblog\/wp-json\/wp\/v2\/categories?post=1163"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.threshold-zero.com\/cblog\/wp-json\/wp\/v2\/tags?post=1163"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}