MySQL Commands - Adding User, Backup and Restore

Adding new user to access the database

Syntax:
mysqldump -u [username] -p [password] [databasename] > [backupfile.sql]

Examples:
mysql> GRANT all ON mydatabase.* TO myuser@'192.168.17.186' IDENTIFIED BY 'mypassword';
mysql> GRANT all ON mydatabase.* TO myuser@'localhost' IDENTIFIED BY 'mypassword';
mysql> FLUSH PRIVILEGES;


Making Backup of the Database

Syntax:
mysqldump -u[mysqluser] -p[password] [databasename] > [destinationfile.sql]

Example:
$ mysqldump -utestaccount -pg3pass employeefile > employeefile-dump.sql

Restoring MySQL Database

$ mysql -uaccount -ppassword employeefile < employeefile-dump.sql

Making Backup of the existing Table

Syntax:
create table <Table Destination> as select * from <Table Source>;

Example:
create table RADUSAGE_09082009 as select * from RADUSAGE;

Comments

Popular posts from this blog

Scraping an Entire Website using LINUX

Radiator Radius Installation connecting to ORACLE (CentOS)

How to enable clustering in Openfire Enterprise?