In this Mysql 8.0 Error tutorial, we will learn why the Authentication error occurs and how we can rectify it through the command line.
It is the most common error which occurs while we set up the Owncloud, WordPress, PhpMyAdmin, etc. This type of error occurs when the applications are not able to establish the connection with the MySQL server due to unknown Authentication method. At that time to rectify this error, we have to check the method by which the application is trying to connect the MySQL Server is correct or not. You can also face the same type of error in MariaDB database server.
To overcome this error, follow the below steps:
For MySQL
- Login to the MySQL database Server with Root User.
mysql -u root -p
- Check the Authentication Method of the MySQL User through which the Application(Owncloud, WordPress etc) is trying to establish the connection.
select user,authentication_string,plugin,host FROM mysql.user;
- Change the Authentication Method from caching_sha2_password to mysql_native_password.
alter user 'User'@'localhost' IDENTIFIED WITH mysql_native_password BY 'Password';
Replace the User and Password with your application’s database User and Password.
For example, we will change the Authentication Method of the Root User.
For MariaDB
- Login to MariaDB database server with the Root User.
mysql -u root -p
- Check the Authentication Method of the MariaDB User through which the Application(WordPress, Owncloud etc.) is trying to establish the connection.
select user,authentication_string,plugin,host FROM mysql.user;
- Run the following command to disable the Authentication plugin in MariaDB server.
ALTER USER root@localhost IDENTIFIED VIA mysql_native_password;
- Now set a new password for the MariaDB Root user.
ALTER USER 'root'@'localhost' IDENTIFIED BY 'strong_password';
- Run the below command in the MariaDB Server to save all the changes.
flush privileges;
Now exit from the MySQL or MariaDB server.
- Restart the Apache or Httpd Service
For Ubuntu / Debian
systemctl restart apache2
For CentOS / Red hat
systemctl restart httpd
Conclusion
In this tutorial, we have learned about the reasons due to which Authentication errors occur. Now with the help of this tutorial you can easily rectify the error.
If you guys have any queries related to this Mysql 8.0 Error tutorial, Let me know in the comments.
Leave a Reply