![]() |
![]() |
![]() |
||||
Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us. |
![]() ![]() |
|
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. |
|
Thread Tools |
![]() |
#1 |
Confirmed User
Join Date: Jan 2001
Posts: 3,539
|
Moving MySQL DBs from one server to another
How do I move some MySQL databases from one server to another? Is there a way to copy the files without doing MySQL commands?
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#2 |
Confirmed User
Join Date: Jan 2002
Location: N.Y.C
Posts: 265
|
yeah you can but ,
you should use mysqldump something like this mysqldump -u username -p dbname > database.db
__________________
![]() |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#3 |
Confirmed User
Join Date: Jun 2002
Location: Seattle
Posts: 1,062
|
If it's the same OS version and filesystems on both you can do db transfers without dumping the database. You _have_ to stop the database on both ends though while you're transferring.
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#4 |
Confirmed User
Join Date: Feb 2001
Location: Puerto Del Carmen, Lanzarote, Canary Islands
Posts: 1,572
|
http://www.mysql.com/
All you need to know about dumping. If systems are the same just copy the data files over as already mentioned. |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#5 |
Confirmed User
Join Date: Jan 2001
Posts: 3,539
|
The database in question is no longer being changed, but it *is* being access. Also, both servers are the same OS/Webserver, just different versions:
Redhat Linux 6.1 / Apache -> Red Hat Linux 7.2 / Apahce |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#6 |
♥♥♥ Likes Hugs ♥♥♥
Industry Role:
Join Date: Nov 2001
Location: /home
Posts: 15,841
|
It depends on the size of your DB. If you have a DB that is small, you may be able to use phpMyAdmin to move the database. Otherwise, you can use phpMyAdmin to export the data (save it as a file), FTP the .sql file to the new server, then log in to the new server and type
/path/to/bin/mysql -u $mysqlusername -p$mysqlpassword $mysqldatabasename < $file.sql I have done it a few zillion times so if you need some help, drop me a line and I will see what I can do.
__________________
I like pie. |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#7 |
Confirmed User
Join Date: Jan 2001
Posts: 3,539
|
Armed & Hammered, hit me up on ICQ, it's in my sig.
I do not have phpMyAdmin, I have Webmin. The database is not very big at all, maybe 1 MB in size. Where are these MySQL databases normally kept in Linux? |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#8 |
Confirmed User
Join Date: Jan 2001
Posts: 3,539
|
Nevermind, I found them in /var/lib/mysql/. Can't FTP to it, no access. Damn.
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#9 |
Confirmed User
Join Date: Feb 2002
Posts: 105
|
HQ,
If you don't have command line access, you can find a PHP or CGI script that will do the backup for you. Then simply FTP the backup file out to your new server. Here is an example, it's a little much though for your needs: http://geeklog.sourceforge.net/sampl...ackup-database This is command line PHP, but you can change that easily by removing the first line, etc. Good luck, PxG |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#10 | |
Confirmed User
Join Date: Jan 2001
Posts: 3,539
|
Quote:
|
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#11 |
Confirmed User
Join Date: Sep 2002
Location: Canada
Posts: 433
|
Since you have root access you can simply tar the var/ directory inside mysql and untar it on the new server....as long as the new version of MySQL supports the table type you used to use you should be fine. I use this method regularly for both backups and database duplication
__________________
![]() ----------- Free automated way to rotate sponsor gallery thumbnails on your sites TgpWizards - Free TGP Gallery submission system |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#12 | |
Confirmed User
Join Date: Jan 2001
Posts: 3,539
|
Quote:
Will I have to shut down mysql first? |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#13 |
Confirmed User
Join Date: Jan 2001
Posts: 3,539
|
.: bump :.
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#14 |
♥♥♥ Likes Hugs ♥♥♥
Industry Role:
Join Date: Nov 2001
Location: /home
Posts: 15,841
|
__________________
I like pie. |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#15 | |
Confirmed User
Join Date: Sep 2002
Location: Canada
Posts: 433
|
Quote:
__________________
![]() ----------- Free automated way to rotate sponsor gallery thumbnails on your sites TgpWizards - Free TGP Gallery submission system |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#16 | |
Confirmed User
Join Date: Sep 2002
Location: Canada
Posts: 433
|
Quote:
However, for the average database, PHPmyadmin is a great program to use. Especially if you're not very unix oriented Edit: Fixed a few grammatical mistakes that made me sound like I was on crack
__________________
![]() ----------- Free automated way to rotate sponsor gallery thumbnails on your sites TgpWizards - Free TGP Gallery submission system |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#17 |
So Fucking Banned
Join Date: Mar 2002
Location: Far out in the uncharted backwaters of the unfashionable end of the Western Spiral arm of the Galaxy
Posts: 893
|
Hey HQ.
Its that simple... 1. Shutdown the MySQL server (on both machine). [mysqladmin shutdown] 2. Copy the DB files of the specific Databases/Tables you want to copy to the other server. 3. start the MySQL server again. Only reservation - Not working on INNODB Tables (for that you will need either to alter the table type or copy it to a duplicate table of type INNODB or do a dump) - but im not sure you are using this. ![]() |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#18 | |
Confirmed User
Join Date: Jan 2001
Posts: 3,539
|
Quote:
|
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#19 | |
Confirmed User
Join Date: Jan 2001
Posts: 3,539
|
Quote:
|
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#20 | |
♥♥♥ Likes Hugs ♥♥♥
Industry Role:
Join Date: Nov 2001
Location: /home
Posts: 15,841
|
Quote:
__________________
I like pie. |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#21 | |
Confirmed User
Join Date: Jan 2001
Posts: 3,539
|
Quote:
|
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#22 | |
♥♥♥ Likes Hugs ♥♥♥
Industry Role:
Join Date: Nov 2001
Location: /home
Posts: 15,841
|
Quote:
__________________
I like pie. |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#23 |
Confirmed User
Join Date: Jan 2001
Posts: 3,539
|
Is phpMyAdmin secure?
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#24 |
So Fucking Banned
Join Date: Mar 2002
Location: Far out in the uncharted backwaters of the unfashionable end of the Western Spiral arm of the Galaxy
Posts: 893
|
Why the hell would you like to install something just o move a database from place to place- nontheless a PHP-remote-admin-tool?
HQ: Yes - what you said is correct. Just copy the directories you want to copy including EVERYTHING in it. Dont need to copy mysql.sock I dont see what might go so wrong that you will have to reinstall mysql like Armed & Hammered said. Armed & Hammered - If you care to elaborate... |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#25 |
Confirmed User
Join Date: Jan 2001
Posts: 3,539
|
The server is brand new with nothing on it... If I have to reinstall mysql, it would be no big deal. If I have to reinstall mysq in a month's time, once it is in full swing, then that would suck.
Yeah, I would rather not install new software on 2 boxes just to copy directories, if that is all I need to do. |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#26 |
Confirmed User
Join Date: Mar 2002
Location: Sweden
Posts: 217
|
I recently moved my DB: I used mysqldump to create a dump SQL file, FTP:ed it to the new server and read it in into my new DB.
One command at each localtion, from command line. |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#27 | |
Confirmed User
Join Date: Jan 2001
Posts: 3,539
|
Quote:
|
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#28 |
♥♥♥ Likes Hugs ♥♥♥
Industry Role:
Join Date: Nov 2001
Location: /home
Posts: 15,841
|
/path/to/bin/mysql -u $mysqlusername -p$mysqlpassword $mysqldatabasename < $file.sql
And there is no need to shut down mysql to dump the DB.
__________________
I like pie. |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#29 | |
Confirmed User
Join Date: Jan 2001
Posts: 3,539
|
Quote:
|
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#30 |
Confirmed User
Join Date: Jan 2001
Posts: 3,539
|
Armed & Hammered, hit me on ICQ.
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#31 | |
Confirmed User
Join Date: Jan 2001
Posts: 3,539
|
Quote:
I do not want to delete the databases, I just want a perfect copy of them for the new server. |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#32 |
Confirmed User
Join Date: Jan 2001
Posts: 3,539
|
When migrating and old mysql database on an old server to a new server should I copy the "mysql" database over too? Or should I just try to manually set that one up the same afterwards?
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#33 |
Confirmed User
Join Date: Feb 2001
Posts: 1,917
|
I'd like to know the answer to this last question, as well...
Anyone? |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#34 | |
Confirmed User
Join Date: Feb 2002
Posts: 105
|
Quote:
Let me understand what you're saying: you're asking whether or not you should move the database named "mysql" over to your new server (from the old). You can do that, since the password hashing algorithm is the same from version to version, but you might have problems with permissions and stuff. In case you didn't know, the mysql db houses all of your user and privilege information. So the users should be OK, everyone will have the same passwords as before, including root. But for things like privileges and such, if you are missing some of the databases that the data in these tables refer to you might have some problems. That's not to say you will, but you have references to things that aren't really there, which is never too good. The other problem is hosts... you might not want the same hosts access to the dbs in your system, etc., but then again maybe everything remains roughly the same for you after the move. Look, it's not that big of a deal to add some users with privileges, I have always done it manually. Hope this helps, PxG |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#35 | |
Confirmed User
Join Date: Feb 2002
Posts: 105
|
Quote:
/path/to/mysqldump -u username -p dbname > dbdumpfile.sql Now you have a dump of the entire database, as of that moment. You don't need to stop your db server, you don't need to reboot or anything like that, just run this command. Then, SSH to you new server and run mysql: /path/to/mysql -u root -p (once logged in and create your db...) > CREATE DATABASE dbname; (now create the user you want) > GRANT all on dbname.* to username@localhost identified by 'passwordhere'; (you can modify the privileges if you dont want to give all) (now log out and dump your old db in) > quit /path/to/mysql -u username -p dbname < dbdumpfile.sql and presto your db is now in your new mysql. (note it will always prompt you for a password when doing this.) If you need more help, just contact us through our URL and we'll set you up. PxG |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#36 | |
Confirmed User
Join Date: Jan 2001
Posts: 3,539
|
Quote:
|
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#37 | |
Confirmed User
Join Date: Jan 2001
Posts: 3,539
|
Quote:
|
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#38 |
♥♥♥ Likes Hugs ♥♥♥
Industry Role:
Join Date: Nov 2001
Location: /home
Posts: 15,841
|
One last thing, once you add new users make SURE you reload mysql so the changes can take effect. I can't tell you how many times I have shot myself in the foot because I didn't reload mysql and therefore couldn't get the username to log in to the DB.
__________________
I like pie. |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#39 |
Confirmed User
Join Date: Feb 2002
Location: Seattle
Posts: 1,070
|
also since the database isn't big it doesn't hurt to run a isamchk or myisamchk - won't take much time at all - just to verify that the data is OK.
isamchk *.ISM i think and myisamchk *.MYI
__________________
![]() |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#40 | |
Confirmed User
Join Date: Sep 2002
Location: Canada
Posts: 433
|
Quote:
__________________
![]() ----------- Free automated way to rotate sponsor gallery thumbnails on your sites TgpWizards - Free TGP Gallery submission system |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#41 | |
Confirmed User
Join Date: Jan 2001
Posts: 3,539
|
Quote:
|
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#42 | |
Confirmed User
Join Date: Jan 2001
Posts: 3,539
|
Quote:
|
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#43 | |
Confirmed User
Join Date: Jan 2001
Posts: 3,539
|
Quote:
|
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#44 |
Confirmed User
Join Date: Jan 2001
Posts: 3,539
|
salsbury, or any one, what is the difference between *.ISM and *.MYI databases? I noticed that some of my older databases are *.ISM and my newer ones are *.MYI. What is the difference?
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#45 |
Confirmed User
Join Date: Jan 2001
Posts: 3,539
|
Bump.
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#46 |
Confirmed User
Join Date: Jan 2001
Posts: 3,539
|
I started a new thread on problems with migration the "mysql" database (all others worked). Here it is:
http://www.gofuckyourself.com/showth...threadid=80312 |
![]() |
![]() ![]() ![]() ![]() ![]() |