I recently had to restore a MySQL backup. It had been a while since I used MySQL, having switched to Postgresql sometime back. First thing I noticed was the lack of a GUI admin tool that PG spoils you with. Making matters worse, the command line tool isn’t even added to your path; you can’t just run “
Here’s what you need to do to restore a MySQL backup on Windows:
- Run the command line tool from the start menu
- Open your backup file in a text editor. Does it start with a command to create or “use” the database? If not
- Create it, if necessary
- Type “use database” filling in your DB name
- Type “source path-to-SQL-file“. BUT, you must follow these rules:
- Use the full source command, not the \. shortcut
- Have no spaces in your path. I copied mine to a root of a drive. Note that spaces in the file name
isOK, just not the path.
- Do not quote the file name, even if it has spaces. This gave error 22.
- Use forward slashes in the path, e.g., C:/path/to/filename.sql.
Otherwiseyou’ll get error 2.
- Do not end with a semicolon.
Follow all those rules and it should work fine.