Backing Up MySQL Database Only With MySQL Command
I've got this very strange web host开发者_运维技巧, it's the weekend and the sysop isn't available, and we need to make changes to the site. To do that, we need a database fallback position, so a database backup. I can SSH in as my user account and found that I can run the "mysql" command line command on Linux just fine. But when I try the mysqldump command, it keeps telling me that user@localhost is not allowed. I read the docs on mysqldump and tried all kinds of variations, and then tried looking at the command itself to see if it was old and if I needed to use older instructions for it.
So, no luck. All we can do is run the mysql command. As well, we tried to install phpmyadmin on this host, but we're having trouble where we get a white page instead of errors, and no way to look at an error log. I did the usual step in PHP to dump out the errors to the screen, but we only get a white page when running phpmyadmin setup.php.
So, is there a way we can use purely the "mysql" command to export our database schema and data?
If you can use the normal mysql command, you should be able to use the mysqldump command as such:
mysqldump -u [username] -p [database name] > [output filename]
For example, is your username is "admin", your database name is "epic_website" and you want to save the SQL into a file in the current directory called "epic_website_20110123.sql", you'd use:
mysqldump -u admin -p epic_website > epic_website_20110123.sql
When you hit return you'll then be asked for the password associated with the "admin" user.
Just export to CSV:
http://ariejan.net/2008/11/27/export-csv-directly-from-mysql/
精彩评论