Site icon LCDUNG

Lệnh MYSQL / MARIADB thường dùng

CREATE USER

CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';
// CREATE USER 'dev'@'localhost' IDENTIFIED BY 'dev@123';
CREATE USER 'newuser'@'%' IDENTIFIED BY 'password';
// CREATE USER 'dev'@'%' IDENTIFIED BY 'dev@123';
SET PASSWORD FOR 'username'@'%' = PASSWORD('passwd');

GRANT USER

GRANT ALL PRIVILEGES ON `db` . `tbl` TO 'dev'@'%';
// GRANT ALL PRIVILEGES ON * . * TO 'dev'@'%';
GRANT ALL PRIVILEGES ON db. * TO dev@'localhost';
// GRANT ALL PRIVILEGES ON * . * TO dev@'localhost';
GRANT ALL PRIVILEGES ON ecommerce . * TO 'admin'@'210.222.000.111';

FLUSH TO APPLY GRANT

FLUSH PRIVILEGES;

COMMAND

Show list user:

SELECT user,host,password FROM mysql.user;

Import database mysql / mysqld:

mysql -u user_root -p --database = db_name < /root/db.sql

Dump database mysql / mysqld:

mysqldump -u user_root -p database_name > /root/database_backup.sql

Copy database

#As the manual says in Copying Databases you can pipe the dump directly into the mysql client:
mysqldump db_name | mysql new_db_name


# Both mysqldump and mysql commands accept options for setting connection details (and much more), like:
mysqldump -u <user name> --password=<pwd> <original db> | mysql -u <user name> -p <new db>
Exit mobile version