Mysql数据库的创建和授权

mysql数据库的创建和字符集的指定


# utf8 字符集
create database  `dbname` default character set utf8 collate utf8_general_ci;

# utf8mb4 字符集
create database  `dbname` default character set utf8mb4 collate utf8mb4_unicode_ci;


mysql数据库的授权,mysql5.x 版本授权方式


# 授权所有权限访问
grant all privileges on dbname.* to user@'%' identified by 'password';

# 授权只读权限访问
grant select on dbname.* to user@'%' identified by 'password';

# 授权增删改查权限访问
grant select,update,insert,delete on dbname.* to user@'%' identified by 'password';

# 刷新权限
flush privileges;


mysql数据库的授权,mysql8 版本授权方式

# 先创建用户
create user 'user'@'%' identified by 'password'; 

# 创建可以使用Navicat连接的加密认证规则用户
create user 'user'@'%' identified with mysql_native_password by 'password';

# 然后再授权
grant all privileges on dbname.* to 'user'@'%' with grant option;

# 刷新权限
flush privileges;

# 修改已有用户加密认证规则
alter user 'user'@'%' identified with mysql_native_password BY 'password';

相关文章

Linux
Mysql5.7基于GTID部署数据库主主模式,并配置nginx负载均衡转发访问
Linux
Mysql5.7基于GTID部署数据库主从模式
Linux
Linux中删除mysql-bin二进制日志文件
Linux
Linux下mysql5.7安装使用
赞赏图片

评论