mysql8创建用户
2019-04-07 本文已影响0人
maxzhao_
基本配置文件 my.cnf
[mysqld]
basedir = D:\mysql
datadir = D:\mysql\data
port = 3336
character-set-server = utf8mb4
default_authentication_plugin=mysql_native_password
[mysql]
default-character-set = utf8mb4
[client]
default-character-set = utf8mb4
数据库初始化:mysqld --initialize
数据库初始化后随机密码在日志文件中hostname.err,需要使用该密码登录并修改密码。
alter user 'maxzhao'@'localhost' identified by "maxzhao";
alter user 'maxzhao'@'localhost' identified with mysql_native_password by "maxzhao";
alter user 'maxzhao'@'localhost' identified with caching_sha2_password by "maxzhao";
MySQL8默认的认证插件是caching_sha2_password,很多客户端都不支持,可将默认的认证插件修改为mysql_native_password,在配置文件中配置default_authentication_plugin=mysql_native_password。
2、创建账号及权限分配
创建账号、分配权限
CREATE USER 'maxzhao'@'localhost' IDENTIFIED BY 'maxzhao';
grant all privileges on . TO 'maxzhao'@'localhost' WITH GRANT OPTION;
CREATE USER 'maxzhao'@'%' IDENTIFIED BY 'maxzhao';
GRANT ALL PRIVILEGES ON *.* TO 'maxzhao'@'%' WITH GRANT OPTION;
CREATE USER 'maxzhao'@'localhost' IDENTIFIED BY 'maxzhao';
GRANT RELOAD,PROCESS ON *.* TO 'maxzhao'@'localhost';
Flush privileges;
#显示账号及权限相关信息
SHOW GRANTS FOR 'maxzhao'@'localhost';
SHOW CREATE USER 'privilegesprivileges'@'localhost';
``