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
Then another problem appeared:
The server requested authentication method unknown to the client
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
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!