[MySQL 8] MySQL8で発生した問題

MySQL8をインストールします

インストール手順

http://dev.mysql.com/get/mysql-apt-config_0.8.16-1_all.deb
dpkg -i mysql-apt-config_0.8.16-1_all.deb

ユーザーの作成、権限の付与、ユーザー情報の変更と削除

MySQL5.7.25

 # 新建、赋予权限
 grant all privileges on *.* to admin@'localhost' identified by 'admins_password' with grant option;
 flush privileges;

# 更改用户 
 ALTER USER 'root'@'localhost' IDENTIFIED BY '你的密码'; 

MySQL 8

# 删除、
drop user admin@localhost;
flush privileges;

# 新建、赋予权限(必须分开进行)
create user admin@localhost identified by 'admins_password';
grant all privileges on *.* to admin@'localhost' with grant option;

# 更改用户
ALTER USER 'root'@'localhost' IDENTIFIED  BY '你的密码';

LaravelはMySQL8に接続しますconfiguremysql

SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client
理由は次のとおりです。
ユーザーの認証タイプはデフォルトcaching_sha2_passwordで。になり、データベース接続エラーが発生し、次の例外がスローされます。
Illuminate\Database\QueryException : SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client
したがって、解決策は次のとおりです。

方法1:MySQL構成を変更する

# /etc/mysql/my.cnf
[mysqld]
default_authentication_plugin = mysql_native_password

systemctl restart mysql

# 重新创建用户(使用  mysql_native_password  模式)
mysql -u root -p
drop user admin@localhost;
flush privileges;
create user admin@localhost identified with mysql_native_password by 'admins_password';
grant all privileges on *.* to admin@'localhost' with grant option;

方法2:laravel構成を変更します(この方法はテストされていません)

参照:https://github.com/laravel/framework/pull/23948

dockermysql8のインストール

Dockerfile:https://github.com/docker-library/mysql/tree/master/8.0

[エラー] [MY-010187] [サーバー]エラーログ用にファイル '/var/log/mysql/error.log'を開くことができませんでした:アクセスが拒否されました

chown 999:999 /var/log/mysql/error.log

mysqld: '/ var / lib / mysql-files'のrealpath()でエラーが発生しました(エラー2-そのようなファイルまたはディレクトリはありません)

# Dockerfile
RUN mkdir /var/lib/mysql-files

おすすめ

転載: blog.csdn.net/qq_22227087/article/details/109555148