MySQL常用语法总结
一,学习mysql的前戏
1:数据库操作
1 创建数据库: 2 create 数据库名; #创建新的数据库 3 create database if not exists 数据库名;#创建数据库前判断有无该数据库,有则不创建,反之则创建 4 create database 数据库门 character set 编码格式;#创建数据库并指定编码格式 5 查询数据库: 6 show databases; #查看当前MySQL中的所有数据库 7 show create datebase 数据库名; #查看数据库创建语句 8 修改数据库: 9 alter database 数据库名 character set 编码方式; 10 删除数据库: 11 drop database 数据库名称; 12 使用数据库: 13 use 数据库名; #使用该数据库 14 查看正在使用的数据库: 15 select database();
2:用户管理及授权
1 #1:用户管理命令 2 创建用户: 3 create user \'用户名\'@\'ip地址\' identified by \'密码\'; 4 删除用户: 5 drop user \'用户名\'@\'ip地址\'; 6 修改用户: 7 rename user \'用户名\'@\'ip地址\' to \'新用户名\'@\'ip地址\'; 8 修改密码: 9 set password for \'用户名\'@\'ip地址\' = Password("新密码"); 10 #2:用户权限管理 11 show grants for \'用户\'@\'IP地址\' -- 查看权限 12 grant 权限 on 数据库.表 to \'用户\'@\'IP地址\' -- 授权 13 revoke 权限 on 数据库.表 from \'用户\'@\'IP地址\' -- 取消权限
权限授权补充
1 all privileges 除grant外的所有权限 2 select 仅查权限 3 select,insert 查和插入权限 4 ... 5 usage 无访问权限 6 alter 使用alter table 7 alter routine 使用alter procedure和drop procedure 8 create 使用create table 9 create routine 使用create procedure 10 create temporary tables 使用create temporary tables 11 create user 使用create user、drop user、rename user和revoke all privileges 12 create view 使用create view 13 delete 使用delete 14 drop 使用drop table 15 execute 使用call和存储过程 16 file 使用select into outfile 和 load data infile 17 grant option 使用grant 和 revoke 18 index 使用index 19 insert 使用insert 20 lock tables 使用lock table 21 process 使用show full processlist 22 select 使用select 23 show databases 使用show databases 24 show view 使用show view 25 update 使用update 26 reload 使用flush 27 shutdown 使用mysqladmin shutdown(关闭MySQL) 28 super
版权声明:本文为sun-10387834原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。