1 --查看系统用户
2 select Host,User,Password from mysql.user;3
4 --创建一个远程用户
5 create user test identified by '123456';6
7 --分配权限
8 grant all privileges on *.* to 'test'@'%'identified by '123456' with grant option;9
10 --刷新mysql用户权限
11 flush privileges;12
13 --修改指定用户密码
14 update mysql.user set password=password('新密码') where User="test" and Host="localhost";15
16 --删除用户
17 delete from user where User='test' and Host='localhost';
-- 查看用户权限
SHOW GRANTS FOR 'group_dc_ro'@'%';
-- 创建用户
create user group_dc_ro identified by '123456';
-- 为用户授权
grant select on mycommunity_bigdata.idw_yl_contract_auth_project_data to 'group_dc_ro'@'%';
-- 用以上命令授权的用户不能给其它用户授权,如果想让该用户可以授权,用以下命令:
grant select on mycommunity_bigdata.idw_yl_contract_auth_project_data to 'group_dc_ro'@'%' with grant option;
-- 刷新数据
flush privileges ;
-- 撤销用户权限
REVOKE select on mycommunity_bigdata.idw_yl_contract_auth_project_data from 'group_dc_ro'@'%';
REVOKE all privileges on mycommunity_bigdata.idw_yl_contract_auth_project_data from 'group_dc_ro'@'%';
-- 设置与更改用户密码
SET PASSWORD FOR 'group_dc_ro'@'%' = PASSWORD('123456');
-- 删除用户
DROP USER 'group_dc_ro'@'%';
--查看mysql支持字符集
show variables like "% character %";
--建立数据库并指定编码
create database app_relation character setutf8;--修改数据库编码
alter database app_relation character set utf8;
CREATE DATABASE db_name DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
CREATE DATABASE 的语法:
CREATE {DATABASE | SCHEMA} [IF NOT EXISTS] db_name
[create_specification [, create_specification] ...]
create_specification:
[DEFAULT] CHARACTER SET charset_name
| [DEFAULT] COLLATE collation_name
更改数据库的字符编码
ALTER DATABASE db_name DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci