Home >Database >Mysql Tutorial >How to Fix phpMyAdmin Authentication Issues with MySQL 8.0?
In the wake of the recent release of MySQL 8.0, users have encountered difficulties accessing phpMyAdmin. This issue stems from an authentication method discrepancy between phpMyAdmin and the server. To resolve this, follow these steps:
First, log in to your MySQL console as the root user using the appropriate command:
mysql -u root -pPASSWORD
Once logged in, change the Authentication Plugin to mysql_native_password by executing the following query:
ALTER USER root IDENTIFIED WITH mysql_native_password BY 'PASSWORD';
When working in a dockerized environment, consider using these commands:
docker run --name mysql -e MYSQL_ROOT_PASSWORD=PASSWORD -p 3306:3306 -d mysql:latest docker exec -it mysql bash mysql -u root -pPASSWORD ALTER USER root IDENTIFIED WITH mysql_native_password BY 'PASSWORD'; exit exit docker run --name phpmyadmin -d --link mysql:db -p 8080:80 phpmyadmin/phpmyadmin:latest
If using the mysql/mysql-server docker image, remember that this solution is for development environments only.
docker run --name mysql -e MYSQL_ROOT_PASSWORD=PASSWORD -e MYSQL_ROOT_HOST=% -p 3306:3306 -d mysql/mysql-server:latest docker exec -it mysql mysql -u root -pPASSWORD -e "ALTER USER root IDENTIFIED WITH mysql_native_password BY 'PASSWORD';" docker run --name phpmyadmin -d --link mysql:db -p 8080:80 phpmyadmin/phpmyadmin:latest
To change the authentication plugin permanently, uncomment the following line in your /etc/my.cnf file:
default_authentication_plugin=mysql_native_password
However, use this method cautiously.
docker run --name mysql -e MYSQL_ROOT_PASSWORD=PASSWORD -e MYSQL_ROOT_HOST=% -p 3306:3306 -d mysql/mysql-server:latest docker exec -it mysql sed -i -e 's/# default-authentication-plugin=mysql_native_password/default-authentication-plugin=mysql_native_password/g' /etc/my.cnf docker exec -it mysql mysql -u root -pPASSWORD -e "ALTER USER root IDENTIFIED WITH mysql_native_password BY 'PASSWORD';" docker stop mysql; docker start mysql docker run --name phpmyadmin -d --link mysql:db -p 8080:80 phpmyadmin/phpmyadmin:latest
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
Ensure the quotes are included as shown.
The above is the detailed content of How to Fix phpMyAdmin Authentication Issues with MySQL 8.0?. For more information, please follow other related articles on the PHP Chinese website!