Posts Tagged ‘ mysql ’

Moving databases from VDS to Managed Hosting with CPanel

Posted in Server Side Stuff on May 1st, 2009 by The Angry Web Designer – 4 Comments Tags: , , ,

What a freaking nightmare! Yeeeesh ….

So after much internal struggle, I descided to close my VDS and move all my stuff to managed hosting. I grew tired of having to maintain stuff, and the requirements were bogging me down from doing other things … like web design :\ So I made the leap and it’s been a nightmare to say the very least.

Everything went smoothly for the scp commands from one server to another. FYI - scp lets you copy files from one server to another so long as you have ssh access. It looks like this;

scp -r /home/www/* user@my.server.com:/home/public-html

That one line of code moved all the files for nine different sites.

BUT … when working with CPanel, even with SSH access, database migration is a pain in the ass. You must first create a database, then add a user, then add that new user to the database, AND THEN you can import your old database into the new one.

I was trying to do a simple;

mysqldump -hlocalhost -uroot -p --all-databases | mysql -hremote_host -uroot -p

but that refused to work. I kept getting a

ERROR 1045 (28000): Access denied for user 'user'@'my.host.com'

So I had to give up on that route.  I moved on to the good o’ll dump method using;

mysqldump -u user -p --all-databases > backup.sql

Which worked really great until I recieved an error from phpmyadmin saying it could not creat the first table … AAARRG.

After some peaking around, it turned out that athough I was logged in as an “admin” - I still did not have write permissions to anything inside of phpmyadmin.

What I had to do (and what would have saved me a lot of headache if I had it this way first);

  1. Create a new database with CPanel’s MySQL Databases module.
    • This creates a database with the correct naming convention required by most CPanel managed hosting accounts.
  2. Next I had to create a user who had permissions to edit the database.
    • This user can have access to one or all of your database in the future.
  3. Then I ssh’d into my VDS and did a
    mysqldumb databasename -u user -p > databasename.sql
  4. After that was done, I copied all the info inside of that file and pasted it into the SQL within phpmyadmin.

So … after 4 hours I have my site backup. Now I get to rinse and repeat for all my other domains as well. Whoooooo HOOOOOOO.

:\

Twitter It!