Restoring a .sql file via shell

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sneekyshadow
    Junior Member
    • May 2004
    • 2

    #1

    Restoring a .sql file via shell

    Hello,

    I had a hard time restoring .sql files through phpmyadmin because it timed out, especially when you have a large MySQL. I found the post by kylec regarding backing up MySQL very good here:

    Backing Up The Database via SSH/Telnet In order to back up your database via SSH you will require 2 things: 1) SSH or Telnet access to your site. 2) An SSH/Telnet Client, such as PuTTy. Open your SSH/Telnet client and log into your website. At the command line: Type in the following: mysqldump -u dbusername -p


    Now, how do I RESTORE the .sql file via shell? I found shell procedures much faster than any other.

    Thanks.
  • chrisd
    Member
    • Mar 2004
    • 44

    #2
    Originally posted by sneekyshadow
    Now, how do I RESTORE the .sql file via shell?
    Presumably your backup file is just INSERT statements.

    There's more than one way - but this is what works for me:
    Code:
    #/>mysql -udbuser_name -puser_password
    
    mysql>use db_name
    
    mysql>source ./path_to_sql_file_name
    You can also execute any valid sql from the mysql prompt ... which comes in handy when your source file explodes and you have to delete * from or DROP TABLE. Enter help or ? for more options.
    Last edited by chrisd; 05-18-2004, 06:44 PM.

    Comment

    • sneekyshadow
      Junior Member
      • May 2004
      • 2

      #3
      Ok thanks chrisd. I'll try this.

      Comment

      Working...