Mysql – How to open a MySQL Database Dump

MySQLmysqldump

I work for a doctor's office, and we are in the process of switching EMR systems. The previous system has provided a physical 'dump' of the database. I however, don't know how to open this database and view the contents therein. The file is 1.2 gb with less then 1000 lines of SQL commands so I assume that all of the data is there. Here's what I've tried thus far:

  • Opened in a text reader: All it shows is a bunch of SQL commands to create the database tables
  • Installed MySQL Workbench and tried to create a "EER Model From SQL Script": This just creates the database structure.
  • Using MySQL Workbench/Setup a 'localhost' server: Tried a 'import' of the .sql file onto the newly created 'server' but it doesn't work and spits out an error

What are some steps to properly opening and obtaining the data found within a MySQL data dump?

I'm VERY new to the whole database management so if I've missed any details feel free to prompt.

Best Answer

Although there are a number of tools out there, I prefer the command line for tasks such as this. Better performance, and just simpler.

Make sure you're logged into the mysql client:

mysql -u <username> -p

The first step is to create a database in mysql that you want the data in:

CREATE DATABASE <database name>;

Then you need to open--or use--that new database, which is empty:

USE <database name>;

All that's left is to do the import:

\. /path/to/file (or if in Windows, \. C:\PATH\TO\FILE)

If all goes well, you'll see a bunch of output about "Query successful, N rows affected" and so on.

Related Question