标签:string code table 操作 用户 character crud rop rev
1、MySQL数据库创建时指定默认的字符集CREATE database $DN_NAME DEFAULT CHARACTER SET utf8mb4 -- UTF-8 Unicode COLLATE utf8mb4_general_ci
> utf8mb4 -- UTF-8 Unicode:字符集;mb4是在utf8的基础上支持了imoji表情。
> utf8mb4_general_ci:是字符排序方式;
> mysql 创建database时最好能明确指定字符集,防止字符混乱的情况发生。
CREATE USER ‘username‘@‘host‘ IDENTIFIED BY ‘password‘;
CREATE USER ‘dog‘@‘localhost‘ IDENTIFIED BY ‘123456‘;
CREATE USER ‘pig‘@‘192.168.1.101_‘ IDENDIFIED BY ‘123456‘;
CREATE USER ‘pig‘@‘%‘ IDENTIFIED BY ‘123456‘;
CREATE USER ‘pig‘@‘%‘ IDENTIFIED BY ‘‘;
CREATE USER ‘pig‘@‘%‘;
单用户授权及其级联授权;
GRANT privileges ON databasename.tablename TO ‘username‘@‘host‘
GRANT ALL privileges ON $DB_NAME.$TAB_NAME to ‘$USER_NAME‘@‘$HOST_IP‘ identified by ‘$RANDOM_STRING‘;
GRANT privileges ON databasename.tablename TO ‘username‘@‘host‘ WITH GRANT OPTION;
SET PASSWORD FOR ‘username‘@‘host‘ = PASSWORD(‘newpassword‘);
SET PASSWORD = PASSWORD("newpassword");
SET PASSWORD FOR ‘pig‘@‘%‘ = PASSWORD("123456");
用户权限撤销
REVOKE privilege ON databasename.tablename FROM ‘username‘@‘host‘;
用户权限查看;
SHOW GRANTS FOR ‘pig‘@‘%‘;
DROP USER ‘username‘@‘host‘;
标签:string code table 操作 用户 character crud rop rev
原文地址:http://blog.51cto.com/mjunetwslinux/2170623