用户
创建用户
create user 'username'@'IP地址' identified by 'password';
IP地址:想任意远程主机登陆,可以使用通配符%
删除用户
drop user '用户名'@'IP地址';
修改用户
rename user '用户名'@'IP地址' to '新用户名'@'IP地址';
修改密码
set password for '用户名'@'IP地址'=Password('新密码');
授权
查看权限
show grants for "用户"@"ip地址";
GRANT privileges ON databasename.tablename TO '用户名'@'IP'
grant select, insert, update on db1.table1 to "用户名"@"%"
grant all privileges on db1.table1 to "用户名"@"%";
grant all privileges on db1.* to "用户名"@"%";
grant all privileges on *.* to "用户名"@"%";
取消授权
revoke all on *.* from "用户名"@"%";
revoke all on db1.table1 from "用户名"@"%";
revoke select on db1.table1 from "用户名"@"%";
数据
-- 备份:数据表结构+数据
mysqdump -u root db1 > db1.sql -p
-- 备份:数据表结构
mysqdump -u root -d db1 > db1.sql -p
-- 导入现有的数据到某个数据库
-- 先创建一个新的数据库
create database db10;
-- 将已有的数据库文件导入到db10数据库中
mysqdump -u root -d db10 < db1.sql -p