php connects to mysql and reports error 2054

藏色散人
Release: 2023-02-27 17:32:01
Original
4906 people have browsed it

php connects to mysql and reports error 2054

php error 2054 when connecting to mysql?

The reason why this happens is mainly because of mysql8.0 version. The default encoding of version 8.0 is utf8mb4

Solution:

Add these two lines under [mysqld] in the MySQL configuration file my.ini

character-set-server = utf8mb4 collation-server = utf8mb4_unicode_ci
Copy after login

Then another problem appeared:

The server requested authentication method unknown to the client
Copy after login

It is also due to the mysql version, the 8.0 version mysql account The password unlocking mechanism is inconsistent

Enter the command in the database operation interface

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'account password';That's it

Or add

default_authentication_plugin=mysql_native_password
Copy after login

under [mysqld] in the MYSQL configuration file my.iniz. For more PHP related knowledge, please visit PHP Chinese website!

The above is the detailed content of php connects to mysql and reports error 2054. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template