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;
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
Post a Comment