Import MySQL File with Command Line

Posted on 2011-10-11
Last Modified: 2012-05-12
Hi guys -

I know little to nothing about MySQL (all of what I know is dedicated to Microsoft...). I have a MySQL export file though that someone made me that's 91mb that won't open in workbench. (I downloaded the free windows client and database).

Workbench just freezes..crashes and then wants me to input a bug request. But I know the problem is because the file is too big since that's what would happen in MS SQL if I tried to open a 91mb sql file.

It's just a bunch of create/insert sql commands to create and load a database. I can open it in WordPad just fine.

I went here:

and I tried that but I have no clue where to type in those commands to make it work. I tried command prompt (Start > Run > cmd). And then I tried the MySQL command client. And then the shell inside Workbench and none of those imported the file.

In command prompt I just got "mysql is unsupported" and then there were syntax errors in the MySQL tools.

So .. how do I infact import this file?

Any help (stupid simple line by line since this is alien technology) would be super appreciated!

Thanks so much!
Question by:rmm2001
    LVL 82

    Expert Comment

    by:Dave Baldwin
    I hope you didn't edit it in Word or Wordpad.  That would probably corrupt the file.  "mysql is unsupported" implies that MySQL is not installed on your computer.

    MySQL programs:

    If the 'mysql' command line program is running, the easiest command to import a MySQL formatted file is:

    mysql -uusername -ppassword databasename < sqlfile.sql
    LVL 7

    Author Comment

    hmm no - i redownloaded it just incased i accidentally did. I still get the same info. The help link you posted is very large and chatty - do I need to really understand all of it or is there an easy way to get this file in?

    WIth MS SQL, there is also a command line utility that I use, bu tthat seems to pop up right out of command prompt (I just type in osql and it appears). When I try typing "mysql" in windows command prompt I just get errors. Does that mean I didn't install something right? Could that be my issue do you think?

    LVL 82

    Accepted Solution

    You need at least this part to get access:

    mysql -uusername -ppassword

    After that you have to select a database and your login must have permissions on that database.  It is not the same model as MS SQL.

    To use this:

    mysql -uusername -ppassword databasename < sqlfile.sql

    all those requirements must be met also.

    What error messages are you getting?
    LVL 7

    Author Closing Comment


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Introduction In this installment of my SQL tidbits, I will be looking at parsing Extensible Markup Language (XML) directly passed as string parameters to MySQL 5.1.5 or higher. These would be instances where LOAD_FILE (…
    Foreword This is an old article.  Instead of using the MySQL extension that was used in the original code examples, please choose one of the currently supported database extensions instead.  More information is available here: MySQLi / PDO (http://…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now