Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Ok, I had a server that was running mysql. It died. I can get into the HD for the old server, but I need to pull the mysql DBs off of it. I don't know how to do this. I found the folder that I believe contains the DBs, but I don't know how to pull them in. (/var/lib/mysql/ )
It's been a while since I last did it, but I think the drill went like this:
Create a database in MySQL on the new machine for each database you want to recover (it should have the same name as the database on the original server). At its most basic, this just involves (e.g.) "create database mydb;"
Stop mysql: sudo /etc/init.d/mysql stop
/var/lib/mysql on both machines should now contain a directory with the same name as the database. These directories will contain (at least) structure, data and index files for each table. Replace the directory on the new machine with the directory on the old. It's probably better to leave the "mysql" system database folder alone, though.
Check permissions on the folders and the files they contain. If the mysql user/group on the new server have a different uid and gid, you will to chown the files before they can be used.
Restart mysql
Create appropriate permissions on the databases.
Back up the databases using mysqldump or similar
I can't remember having too much trouble getting it to work.
Distribution: Ubuntu/Debian, CentOS, RHEL, FreeBSD, OS X
Posts: 71
Rep:
onthefrit,
If your database only had its tables using the MyISAM storage engine, then you can simply copy over the /var/lib/mysql/YOURDATABASE to the new server. As long as the permissions are set properly, it should be accessible within your new MySQL server.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.