mysql經常使用命令

mysql用戶管理
MySQL建立用戶以及受權
grant all on . to ‘user1’ identified by ‘passwd’;
grant SELECT,UPDATE,INSERT on db1. to ‘user2’@’192.168.133.1’ identified by ‘passwd’;
grant all on db1.
to ‘user3’@’%’ identified by ‘passwd’;
show grants;
show grants for user2@192.168.133.1;mysql

經常使用sql語句
select count() from mysql.user;
select
from mysql.db;
select db from mysql.db;
select db,user from mysql.db;
select * from mysql.db where host like ‘192.168.%’;
insert into db1.t1 values (1, ‘abc’);
update db1.t1 set name=’aaa’ where id=1;
truncate table db1.t1;
drop table db1.t1;
drop database db1;sql

FLUSH PRIVILEGES數據庫

mysql數據庫備份恢復
備份庫 mysqldump -uroot -p123456 mysql > /tmp/mysql.sql
恢復庫 mysql -uroot -p123456 mysql < /tmp/mysql.sql
備份表 mysqldump -uroot -p123456 mysql user > /tmp/user.sql
恢復表 mysql -uroot -p123456 mysql < /tmp/user.sql
備份全部庫 mysqldump -uroot -p -A >/tmp/123.sql
只備份表結構 mysqldump -uroot -p123456 -d mysql > /tmp/mysql.sqlide

相關文章
相關標籤/搜索