在Ubuntu20.04下的mysql8.0中如何让mysqld以default_authentication_plugin=mysql_native_password运行
时间: 2024-03-13 21:45:21 浏览: 18
在 Ubuntu 20.04 下的 MySQL 8.0 中,您可以通过以下步骤让 mysqld 以 `default_authentication_plugin=mysql_native_password` 运行:
1. 停止 MySQL 服务:
```
sudo systemctl stop mysql
```
2. 修改 MySQL 配置文件 `/etc/mysql/mysql.conf.d/mysqld.cnf`,在 `[mysqld]` 节点下添加一行:
```
default_authentication_plugin=mysql_native_password
```
3. 保存并关闭配置文件。
4. 启动 MySQL 服务:
```
sudo systemctl start mysql
```
现在,mysqld 将以 `default_authentication_plugin=mysql_native_password` 运行。请注意,如果您选择了其他身份验证插件,则需要相应地更改 `default_authentication_plugin` 的值。
相关问题
在Ubuntu20.04中的mysql8.0中如何使用--default_authentication_plugin=mysql_native_password运行mysqld
在 Ubuntu 20.04 中安装 MySQL 8.0 后,可以使用以下命令来使用 `--default_authentication_plugin=mysql_native_password` 运行 `mysqld`:
```
sudo mysqld --default_authentication_plugin=mysql_native_password
```
如果你使用的是 systemd 来管理 MySQL 服务,可以在 `/etc/systemd/system/mysqld.service.d/mysqld.conf` 文件中添加以下内容:
```
[Service]
ExecStart=
ExecStart=/usr/sbin/mysqld --default_authentication_plugin=mysql_native_password
```
然后重新加载 systemd 配置并重启 MySQL 服务:
```
sudo systemctl daemon-reload
sudo systemctl restart mysqld
```
需要注意的是,在 MySQL 8.0 中,默认的认证插件是 `caching_sha2_password`,所以如果你使用 `--default_authentication_plugin=mysql_native_password` 参数启动 `mysqld`,则需要创建一个用户并指定其认证插件为 `mysql_native_password`。例如:
```
CREATE USER 'myuser'@'localhost' IDENTIFIED WITH mysql_native_password BY 'mypassword';
```
这将创建一个用户名为 `myuser`,密码为 `mypassword`,并使用 `mysql_native_password` 作为认证插件的用户。
在Ubuntu20.04下如何使mysqld 以 --default_authentication_plugin=mysql_native_password 方式运行
你可以按照以下步骤在 Ubuntu 20.04 下让 mysqld 以 --default_authentication_plugin=mysql_native_password 方式运行:
1. 打开 MySQL 配置文件 my.cnf:
```
sudo nano /etc/mysql/my.cnf
```
2. 在文件中添加以下行:
```
[mysqld]
default_authentication_plugin=mysql_native_password
```
3. 保存并关闭该文件。
4. 重启 MySQL 服务:
```
sudo systemctl restart mysql
```
现在,mysqld 将使用 mysql_native_password 作为默认的身份验证插件。