I’ve spent all morning trying out different MySQL database commands to restore a .sql file (database backup file) on a server through SSH. Just as I was about to give up I got the right sequence of letters and numbers to appease the angry monster.
(this is more for my future benefit than anything else)
mysql -u (MySQL username) -p (Database Name) < (name of the text or sql file)
- I have to write the username after -u BUT I don’t write the password after -p.
- The “<” points to the direction of the action. So the sql file restores to the database.
mysql -u clay -p mydatabase < backup.sql
I read a lot of blogs, tutorials and MySQL manuals today and tried mysqldump, mysqlimport and just about every other sensible sounding command. I finally tried the simple ‘mysql.’
If you know your way around MySQL, you may be saying ‘duh,’ but by posting it here, I will be sure to remember it!