Filed under:

How can I RESTORE a MySQL database from the command line?




Importing a MySQLDUMP

From your SSH command prompt type ...
mysqladmin -u {username} -p {password} create {databasename}
mysql -u {username} -p {password} < {databasename.sql}

Replace the parameters with the appropriate values

  • {username} - this is your database username
  • {password} - this is the password for your database
  • {databasename} - the name of your database
  • {databasename.sql} - the file to which the backup should be written.

Depending on your Unix/Linux version you may need to type the full path i.e. /usr/local/mysql/bin/mysql instead of just mysql

The {databasename.sql} shoudl contain all the SQL statements needed to create the tables and populate them with their current contents.

Example To restore your database myuser_portal with the database username mydbuser and database password mydbpassword from a file portal.sql, you would type the commands:

mysqladmin -u mydbuser -pmydbpassword create myuser_portal
mysql -u mydbuser -pmydbpassword < portal.sql



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read

Language: