mysql


3
Sep 07

Migrating your MySQL database from Dreamhost

Those of you who are still using the Dreamhostess with the Mostest (downtime) are probably looking for another solution for your webby goodness after the networking train wreck of the past few months (1, 2, 3, 4, 5, 6, you get the picture. By the way, if this sounds like awesome hosting to you, by all means, use my referral link when you signup with them! ).

You know I’m in love with Slicehost, for all the wrong reasons (they tease me with wait lists to even sign up, then they hit me with the pure root goodness, and I’m jonesing for another hit). I’ve got my Debian VPS all setup to roll, just need to get my data from Dreamhost over to the new server.

Website files? No problem. I used handy old rsync, and even put together a little bash script that I reference from a cron job, to do regular syncing of the Dreamhost data until I’m ready to go live with the new site.

But what about the database? My websites are all database driven, which mean no MySQL migration = no website! I tried using the phpmyadmin interface first, and simply exporting / importing the database from one install to another. Well, the database file is about 30 MB (this is a pretty big blog we’re moving), so that’s right out!

What’s a noob server admin to do?

mysqldump

Command Line to the rescue! Shut down that phpmyadmin, and crank up ye olde terminal. SSH into your new server, the one you are migrating to, and run the following command. The username and password in the first part should be for the MySQL database you are migrating FROM, the second part of the command should use the username and password you are migrating TO. Everything in CAPS should be replaced with your own details. No line breaks, put the whole thing on a single line:

Now that is Easy Breezy Covergirl!

IP Access on Dreamhost

If you’re moving your database away from Dreamhost, you’ll need to do a little unlocking of the database first. Dreamhost restricts access to your databases by IP address (or the resolved domain name equivalent). This a good thing, a security feature, but it will thwart our attempts to use mysqldump from our new server. No worries, you can add access for whatever IP your new server is on. Here’s how it works.

From your Dreamhost control panel, hit Goodies >> Manage MySQL. Locate the database you’re migrating, then click on the USERNAME next to the database. It will take you to a page that lets you manage the privileges for that user. Toward the bottom, find the option for “Allowable hosts.” It will look something like this:

allowable hosts

The %.dreamhost.com line should be there by default, allowing any dreamhost server to get at your data.

You will need to add a new line, containing the IP address (or IP range using wildcards) for the server you intend to migrate to. Note that the IP address they list beneath this is the IP address for your current browser connection to the control panel, not the IP address you need to use in order to allow server access from your new machine. Don’t be fooled!

If you are on Slicehost, you have a dedicated IP number that you can use here.

Save, exit, run the command line for mysqldump from your new machine, and you should get a clean import of your database into the new server.

Taste the Freedom!

PS. Don’t cancel that dreamhost account just yet, though. Sometime in the future, I’ll show you how I used .htaccess on my new server to treat my dreamhost account like a big ole’ hard drive for storing and serving large media files.

Make Dreamhost your bandwidth bitch!

Popularity: 26% [?]


14
Jul 07

apache2, php5, phpmyadmin

So, I solved at least one of my nagging headaches. I ran into a brick wall trying to get phpmyadmin up and running on ubuntu.

The Setup

Ubuntu 7.04, Apache2.2, MySQL, PHP5, running on a VPS from slicehost.com. All installed from apt-get, all working fine. Gave MySQL root user a password, the login to MySQL from the command line works just fine.

Installed phpmyadmin from apt-get, everything’s cool, it sets up the appropriate symbolic links so that www.MYURL.com/phpmyadmin points the browser to the phpmyadmin login page.

The Problem

I go to www.MYURL.com/phpmyadmin, and I get the login page. I enter the MySQL user root + password. Sometimes it logs in. Sometimes it bounces me back to the login with no warning. Sometimes it redirects me to the login page and says “root”@”localhost” not permitted [password=YES]. Sometimes it’s the same warning, but with [password=NO], even though I have entered a password.

Sometimes, if I click login 3 or 4 times after it keeps redirecting me, I actually get let in to phpmyadmin. As soon as I do anything requiring privileges (create new user, create new database), I get bounced back to the login page again.

Troubleshooting

Here’s what I tried to fix it

1) Tried all browsers at my disposal (OSX: Firefox, Opera, Safari, Camino; Windows: IE6, IE7). Same problem with all.

2) Assumed it was a cookie issue. Dumped all cache and cookies on my browser, reset safari, relaunched apache2, tried again. Same problem.

3) Same as step 2, but also did a shutdown -r of the entire server, just in case. Old habits die hard.

3) Sacrificed male goat by the light of a full moon. Sticky fingers, but still no persistent login.

Nothing worked.

The Solution

Turns out, in order to run phpmyadmin with php5 on a 64bit ubuntu machine, you need to have a little package installed called php5-mcrypt. It’s not listed in the dependencies, so if you just use apt-get, it gets left behind.

sudo apt-get install php5-mcrypt

the conclusion

aaaarrrrrgh.

Let the record show that it was at this precise moment in time that I switched from Ubuntu to Debian for my server needs. If I wanted to shed this much stomach bile on figuring out required dependencies, I would strap on a pocket-protector and go join the gentoo geeks. At least then I know it’s up to me.

Popularity: 19% [?]