Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

MySql Help

Options
  • 27-06-2006 10:52pm
    #1
    Closed Accounts Posts: 135 ✭✭


    Trying to restore a Database from the command line using the following syntax

    mysqlimport -u root --password=abc123 testdb c:\test.sql

    but when i execute it i get the following error

    mysqlimport: Error: Table 'testdb.test' doesn't exist, when using table: test

    any ideas on why it won't read the sql file?


Comments

  • Closed Accounts Posts: 8,866 ✭✭✭Adam


    Does the sql file contain a create database line?


  • Closed Accounts Posts: 135 ✭✭Splendid


    Yeah, it's a backup from the MySql Administrator.
    I could use it to do the restore but i need this for something else.


  • Registered Users Posts: 2,426 ✭✭✭ressem


    Is the mysql table actually called test?


    According to the mysqlimport web page

    It strips the extension from the c:\test.sql and uses it as the database table to operate on.

    The table needs to exist already.
    Usually to get around this, the sql file, or just the create part is redirected into mysql instead.

    mysql -u root -p -D testdb < test.sql


  • Closed Accounts Posts: 135 ✭✭Splendid


    ressem wrote:
    Is the mysql table actually called test?


    According to the mysqlimport web page

    It strips the extension from the c:\test.sql and uses it as the database table to operate on.

    The table needs to exist already.
    Usually to get around this, the sql file, or just the create part is redirected into mysql instead.

    mysql -u root -p -D testdb < test.sql

    No the dump of the entire database is called test.sql

    I'll try the above thanks, any tutorial i found just didn't work properely, they all say the code i posted shoud run a restore for the entire db.


  • Closed Accounts Posts: 8,866 ✭✭✭Adam


    It should be very simple, I have done this many times before. Basically you just have to create the database and execute the batch sql statement.


  • Advertisement
  • Closed Accounts Posts: 135 ✭✭Splendid


    The script i'm trying to execute has the create databse in it.


  • Registered Users Posts: 2,426 ✭✭✭ressem


    The script i'm trying to execute has the create databse in it.

    which will work if you send through mysql, but not mysqlimport (unless there's some argument I havn't spotted)



    from man page of mysqlimport
    For each text file named on the command line, mysqlimport strips any extension from the filename and uses the result to determine the name of the table into which to import the file's contents. For example, files named patient.txt, patient.text, and patient all would be imported into a table named patient.

    So 1 file required per table.


  • Closed Accounts Posts: 135 ✭✭Splendid


    Ah right, thats great i'll try that when i get home.
    Damn stupid internet tutorials.

    Thanks for all the help lads.


  • Registered Users Posts: 2,426 ✭✭✭ressem


    And would help if I was more precise.
    When working with mysqlimport,
    you will usually work with "mysqldump --tab=dirname databasename"

    For each table of the database, this creates, in the file directory dirname, a text file with the table data and an sql file for the table structure.

    Then you would use 'mysql < tablename.sql'
    together with 'mysqlimport dbname tablename.txt'

    Intended for high speed use. For simple use
    just use mysqldump on its own, then direct straight into mysql.


  • Closed Accounts Posts: 135 ✭✭Splendid


    Thanks ressem, if i had read your post properely i would have noticed that it was mysql and not mysqlimport.

    Will try it later and report back.


  • Advertisement
  • Closed Accounts Posts: 135 ✭✭Splendid


    ressem wrote:
    mysql -u root -p -D testdb < test.sql

    Perfect, worked first time. Thanks a million.


Advertisement