MySQL 8.0 安装及修改密码

2023/08/0114:45:10MySQL 8.0 安装及修改密码已关闭评论

1. 安装MySQL

sudo apt install mysql-server mysql-client

2. 启动MySQL

sudo systemctl start mysql.service

3. 登录MySQL并修改密码

mysql -uroot
alter user'root'@'localhost' identified with mysql_native_password by 'yourpassword';
flush privileges;

全局更改默认的身份验证插件
如果你想要改变新用户默认的密码插件为 mysql_native_password,你可以在 MySQL 的配置文件中设置这个选项。这通常在 /etc/my.cnf、/etc/mysql/my.cnf 或在 MySQL 数据目录下的 my.cnf 文件中配置。打开你的 MySQL 配置文件(例如 my.cnf)。
在 [mysqld] 部分添加或更新以下行:

[mysqld]
default_authentication_plugin=mysql_native_password

4. 创建账户

# 创建账户
create user root@'%' identified by 'yourpassword';
# 授权用户
grant all privileges on *.* to root@'%';
grant all privileges on *.* to root@localhost;
  • 微信扫码赞助
  • weinxin
  • 支付宝赞助
  • weinxin