Restoring a database from shell and sql dump

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Brian Sadler

    Restoring a database from shell and sql dump

    Does anyone know where I can find information on how to setup my shell in
    unix/linux to allow me to restore a database from an sql dump...

    Example...

    I have a database on 83200.mysql.com (example) that I have a file mysql.sql
    (also just an example).

    The file was produced using an sqldump command from a web interface...

    How can I configure a connection if I am not on 83200.mysql.com so that I
    can import the data into a database with a name of database_wordpr ess

    Any help is greatly appreciated.

  • Gordon Burditt

    #2
    Re: Restoring a database from shell and sql dump

    >Does anyone know where I can find information on how to setup my shell in[color=blue]
    >unix/linux to allow me to restore a database from an sql dump...[/color]

    You need to install the command-line client for your database, for
    your example, it's called 'mysql' and might reside in /usr/local/bin/mysql,
    on whatever machine you are doing this from.
    [color=blue]
    >Example...
    >
    >I have a database on 83200.mysql.com (example) that I have a file mysql.sql
    >(also just an example).
    >
    >The file was produced using an sqldump command from a web interface...[/color]

    If you just want to run the sql:

    mysql -h 83200.mysql.com -u your_username -pyour_password database_wordpr ess < mysql.sql

    [color=blue]
    >How can I configure a connection if I am not on 83200.mysql.com so that I
    >can import the data into a database with a name of database_wordpr ess[/color]

    The host, username, password, and database parameters are for those
    of the *DESTINATION* database. Depending on how the sqldump command
    was done, it may have the database name(s) embedded in the mysql.sql
    file and you might have to edit that file to change it. mysqldump
    can, for example, put dumps of all tables in all databases into a
    sql dump file, and it will switch databases inside the file.

    Your database might be set to only allow direct database access
    from specific hosts (like localhost only), "for your security". If
    your database is run by a hosting company, there may be no way
    around this restriction, other than putting your database on your
    own server, or changing hosting companies.

    Gordon L. Burditt

    Comment

    Working...