Ubuntu 安装配置 Mysql8

Felix 2020年11月14日 15次浏览

安装

apt update
apt-get install mysql-server
service mysql restart
service mysql status

配置

mysql -u root #进入mysql
use mysql; #使用mysql库
select host,user from user; #查看当前用户
CREATE USER 'admin'@'%' IDENTIFIED BY '123456'; #创建新用户
grant all privileges on *.* to 'admin'@'%'; #授权新用户
DELETE FROM user Where User='admin' and Host='%'; #删除用户
flush privileges; # 刷新权限


alter user 'root'@'%' identified by '12345678' password expire never; #将用户root密码设置为永不过期
alter user 'root'@'%' identified with mysql_native_password by '12345678'; #将root用户密码加密方式改为mysql_native_password ,上面查到root用户密码的加密方式为caching_sha2_password