MySQL dump & restore database

To take dump of any database use following.

[root@superbox]#  mysqldump –opt databasename -p > databasedump.sql

To restore existing dump to new database.

* Login in mysql

[root@superbox]# mysql -uroot -p

* Create new database.

mysql> create database <databasename>;

* Create user with access for that particular database.

mysql> GRANT ALL on <databasename>.* to <username>@localhost identified by ‘yourpassword’;

* Now restore existing dump to new database using old dump file.

[root@superbox]# mysql -uroot(or username) -p databasename < /path/to/databasedump.sql

It will take time as per your database size.

Advertisements
This entry was posted in LAMP. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s