Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
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.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Recently I screwed my server up by changing a permission and then it got worse and worse with my tinkering. Anyway, I am going to reinstall Linux (needed to get newer mandrake anyway), but ran into a problem backing up mySql databases. I cannot connect properly to use mysqldump (in fact, I cannot connect to any user besides root via ssh). I found my database directory (/var/lib/mysql/the_dir_I_need). I tarred that directory and was wondering if that would be good enough for a backup? Can I just untar the directory after clean install? Any input would be great.
The best way of backing up any SQL database, is by exporting it. If you are doing a filesystem dump, you must make sure that the database isn't running, or you are getting a copy of a possible inconsistent database. (not that mysql really does much to make sure it is consistent in the first place, some will claim that mysql isn't really a RDBMS at all)
The backup command for mysql is named mysqldump
In its simplest form it works something like this:
mysqldump -a -u user -p database > export_file.sql
It generates a bunch of SQL queries that can be used to recreate the database as it was, so you can simply use the mysql command to restore it. You can also, just by editing it, restore only parts of it.
Originally posted by ttolst The best way of backing up any SQL database, is by exporting it. If you are doing a filesystem dump, you must make sure that the database isn't running, or you are getting a copy of a possible inconsistent database. (not that mysql really does much to make sure it is consistent in the first place, some will claim that mysql isn't really a RDBMS at all)
The backup command for mysql is named mysqldump
In its simplest form it works something like this:
mysqldump -a -u user -p database > export_file.sql
It generates a bunch of SQL queries that can be used to recreate the database as it was, so you can simply use the mysql command to restore it. You can also, just by editing it, restore only parts of it.
And if you read his post, he states clearly that the given command to do it properly isn't working, he's trying to find alternatives.
Thanks for the replies. I know the correct way to backup my databases, but seeing I can't connect it is useless. I'll definitely hope that just backing up the directory will work this time (and now I know to make daily backups hehe). Thanks, everyone!
Originally posted by bifur Thanks for the replies. I know the correct way to backup my databases, but seeing I can't connect it is useless. I'll definitely hope that just backing up the directory will work this time (and now I know to make daily backups hehe). Thanks, everyone!
Like I said, just grabbing the db directories out of /var/lib/mysql should work, though I've never grabbed the default mysql db, that I just recreated with a new install/new host, etc.
The worst that can happen is you lose some data or some is corrupt, easily just removing and rebuilding, etc.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.