Article Directory
Install 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
Create users, grant permissions, change and delete user information
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 connect to MySQL8 configure mysql
SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client
The reason is: the
user’s Authentication type defaults tocaching_sha2_password
, which leads to a database connection error and throws the following exception:
Illuminate\Database\QueryException : SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client
So the solution is as follows:
Method 1: Modify the MySQL configuration
# /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;
Method 2: Modify the laravel configuration (this method is not tested)
Reference: https://github.com/laravel/framework/pull/23948
docker mysql8 installation
Dockerfile:https://github.com/docker-library/mysql/tree/master/8.0
[ERROR] [MY-010187] [Server] Could not open file ‘/var/log/mysql/error.log’ for error logging: Permission denied
chown 999:999 /var/log/mysql/error.log
mysqld: Error on realpath() on ‘/var/lib/mysql-files’ (Error 2 - No such file or directory)
# Dockerfile
RUN mkdir /var/lib/mysql-files