1 创建用户
CREATE USER 'username'@'host' IDENTIFIED BY 'password';
比如
create user 'test_user'@'%' identified by 'test';
ps:如果只允许本机登录则host=localhost,如果允许从任意远程主机登陆则host=%
修改密码
SET PASSWORD FOR 'username'@'host' = PASSWORD('newpassword');
2 授权
GRANT privileges ON dbname.tablename TO 'username'@'host'
比如
GRANT ALL ON test_db.* TO 'test_user'@'%';
撤销权限
REVOKE privilege ON dbname.tablename FROM 'username'@'host';
3 查看某个用户的授权
show grants for test_user;
4 数据导出
$ mysqldump -u dbuser -p dbname [tablename1] [tablename2] > dump.sql
ps:tablename可选
5 数据导入
mysql>source /path/dump.sql
或者
$ mysql -uusername -p dbname < dump.sql
6 定位问题
mysql>show processlist;
mysql>show variables;