0

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?

2
  • 1
    If you can use the command line mysql to connect to and query your database, then mysqldump should work fine - what was going wrong/what errors were being reported? Commented Jan 23, 2011 at 19:55
  • It said "user@localhost" access denied. (I can't reveal who "user" was of course, but it was the user I used properly through the mysql command.) Also, I tried --user "user@localhost", --user "[email protected]", and --user "user" -- all to no avail. Commented Jan 23, 2011 at 20:25

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks @middaparka. I don't know what I was doing wrong, actually. It's working now using your syntax! I have no understanding why. However, then that means that this question is a duplicate of other questions like this. I wonder if I should put in a delete of this question?
@Volomike There's no need to delete questions on StackOverflow. (This question would have been closed as a duplicate by now otherwise.) If there's an issue in future, questions can be merged, etc. as required. Glad it's all sorted. :-)
0

Just export to CSV:

http://ariejan.net/2008/11/27/export-csv-directly-from-mysql/

2 Comments

This is about as much use as a chocolate teapot if they need to restore the data in a hurry. :-)
You can restore quickly with csv, something like: load data local infile 'whatever.csv' into table whatever fields terminated by ',' enclosed by '"' lines terminated by '\n'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.