Home > Database > Mysql Tutorial > How to Fix phpMyAdmin Authentication Issues with MySQL 8.0?

How to Fix phpMyAdmin Authentication Issues with MySQL 8.0?

Linda Hamilton
Release: 2024-11-24 03:41:13
Original
225 people have browsed it

How to Fix phpMyAdmin Authentication Issues with MySQL 8.0?

phpMyAdmin on 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:

Log in to MySQL Console

First, log in to your MySQL console as the root user using the appropriate command:

mysql -u root -pPASSWORD
Copy after login

Change Authentication Plugin

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';
Copy after login

Dockerized Environment

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
Copy after login

mysql/mysql-server

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
Copy after login

Uncommenting in /etc/my.cnf

To change the authentication plugin permanently, uncomment the following line in your /etc/my.cnf file:

default_authentication_plugin=mysql_native_password
Copy after login

However, use this method cautiously.

Updated Workaround (01/30/2019)

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
Copy after login

Updated Solution (09/13/2021)

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
Copy after login

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template