How do I import a file?

Posted on 2006-04-17
Last Modified: 2012-08-13
HOW d i import a dump file into mySql. I was trying to do piece by piece but I was getting errors.

  Here is the first line of the dump file.      
-- MySQL Administrator dump 1.4
-- ------------------------------------------------------
-- Server version      4.1.16-nt

I think I should do this on the command line, but I not know how.

Question by:baybook
    LVL 11

    Expert Comment

    use mysqldump
    LVL 11

    Expert Comment

    you can do
    mysql -h <dbname> -u<user-name> -p<passwd> --local-infile=1 {db-name} < {sql-file}
    LVL 11

    Expert Comment

    {sql-file} can be
    LOAD DATA LOCAL INFILE <file-name> INTO TABLE <table-name>;
    //you can also mention fields terminated by \t or , default is \t
    LVL 26

    Assisted Solution


    If the dump is generated by mysqldump utitlity ..

    From command prompt..

    shell>mysql -uusername -ppassword db_name < dumpfile.sql

    If you are already running mysql, you can execute an SQL script file using the source or \. command:

    mysql> source dump.sql
    mysql> \. dump.sql


    Author Comment

    in which directory do I place the .sql file that I want to import?

    LVL 11

    Accepted Solution

    you can place any where, however it is better to place it in the current directory.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Foreword In the years since this article was written, numerous hacking attacks have targeted password-protected web sites.  The storage of client passwords has become a subject of much discussion, some of it useful and some of it misguided.  Of cou…
    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://…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    760 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

    8 Experts available now in Live!

    Get 1:1 Help Now