/*2016-5-5*/
--草草看完了《SQL完全手册》,开始MYSQL语法的学习
--还要卧床半个月,无聊,,,,/*MySQL这样选择数据库字符集和数据库校对规则:
·如果指定了CHARACTER SET X和COLLATE Y,那么采用字符集X和校对规则Y。
·如果指定了CHARACTER SET X而没有指定COLLATE Y,那么采用CHARACTER SET X和CHARACTER SET X的默认校对规则。
·否则,采用服务器字符集和服务器校对规则。
如果在CREATE TABLE语句中没有指定表字符集和校对规则,则使用数据库默认的字符集和校对规则作为默认值。*/
--grant select,update,insert on mysql.* to guest@localhost indentified by 'guest123'报错,GRANT之前需要用户实际存在
--创建在本地登录的用户guest,其登录密码为guest123(登录密码是不是就是用户密码本身?接下来要实验)
create user 'guest'@'localhost' identified by 'guest123'
--创建数据库guest且字符集为UTF-8,校对规则为utf8_bin
create database guest default character set utf8 collate utf8_bin
--2016.5.16后记:--MySQL5.6已经改成 utf8_general_ci;且校对规则一般不需指定,默认字符集对于一个响应的校对规则
--将insert,update,select的权限赋予在本机登录时的guest
grant insert,update,select on mysql.* to 'guest'@'localhost'
--收回本机登录时的guest所拥有的insert,update,select权限
revoke insert,update,select on mysql.* from 'guest'@'localhost'
--将insert,update,select的权限赋予在本机登录的guest并允许其再授权
grant insert,update,select on mysql.* to 'guest'@'localhost' with grant option
--实验identified by语句定义的密码是登录密码还是用户密码,
create user 'guest1'@'localhost'--在此不identified
--查询mysql库中User表的authentication_string字段是否为空
use mysql;
select authentication_string from user where user = 'guest1'
查询结果如图,无内容
select authentication_string from user where user = 'guest'
设置过密码的查询结果如图,有加密的码
参照了http://my.oschina.net/u/1179414/blog/202377的文章。