Restoring a database from shell and sql dump

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
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...


I have a database on  (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 so that I
can import the data into a database with a name of database_wordpress

Any help is greatly appreciated.

Re: Restoring a database from shell and sql dump

Quoted text here. Click to load it

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.

Quoted text here. Click to load it

If you just want to run the sql:

mysql -h -u your_username -pyour_password database_wordpress <

Quoted text here. Click to load it

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

Site Timeline