Thursday, January 10, 2013

Executing a very large .sql file from mysql command line

Today, I finally managed to get this to work.

I am working on a Windows 2008 server using Wamp with mysql 5.5.24.

On my server, I opened a command window and changed to mySQL directory

c:\wamp\bin\mysql\mysql5.5.24\bin

I created a mysql session by issuing the following command from the DOS prompt

c:wamp\bin\mysql\mysql5.5.25\bin> mysql  -u  username -p dbname










I was prompted for the password for the username supplied.

The mysql> prompt and a MySQL connection id indicates a session has begun.

Typing \s at the mysql> prompt provides information about the session










With a connection made, and a database selected, I used this command to run my .sql file.

mysql> source pathtofolder\filename.sqlsource

  

 

This command executed  the 240 MB .sql file, restoring my entire moodle database in about 2 minutes! The GUIs (phpmyadmin, MySQL Workbench) took much much longer and required me to break the file into multiple files.







4 comments:

  1. this is one of my favorite posts

    ReplyDelete
  2. once again, I used this post. I wish I could star it or shortcut it.....

    thanks james.....i wonder why I so relate to the authors writing style and insights?

    ReplyDelete
  3. You are a funny guy, James -- nice post!

    ReplyDelete