systemctl restart mysqld //重启mysql服务
select host,user,authentication_string,plugin from user;
update user set authentication_string='' where user='root'; //清空认证密码
alter user 'root'@'localhost' identified by 'smtc123456'; //修改密码
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'smtc123456' PASSWORD EXPIRE NEVER;
flush privileges;
exit8;
show variables like 'port'; //查看linux端口号
MySQL——MySQL8创建用户及分配权限
创建数据库
CREATE DATABASE IF NOT EXISTS mes charset utf8 COLLATE utf8_general_ci;
创建用户
create user 'myuser'@'%' identified by 'smtc123456';
修改用户 放开远程连接所以权限
update mysql.user set host = "%" where user = "myuser";
分配用户权限
grant all privileges on mini_shop.* to "myuser"@'%' ;