Tag Archives: mysql8

[Solved] MYSQL8 Error: ERROR 2003 (HY000): Can’t connect to MySQL server on ‘localhost’ (10061)

1:stop serves: net stop mysql
2:remove serves: mysqld -remove mysql
3:E:\zyf\mysql8\bin>mysqld -initialize-insecure -user=mysql
4:E:\zyf\mysql8\bin>mysqld -install mysql
5:E:\zyf\mysql8\bin>net start mysql
6:E:\zyf\mysql8\bin>mysql
Error: ERROR 1045 (28000): Access denied for user ‘ODBC’@’localhost’ (using password: NO)
7:E:\zyf\mysql8\bin>mysql -uroot -p
Enter password: *******
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 10  Then you can log in normally!
If you encounter Navicat can’t connect to mysql service: Error reported.

You can start by logging into mysql in a DOS command window at
Then run: mysql> ALTER USER ‘root’@’localhost’ IDENTIFIED WITH mysql_native_password BY ‘root123’;
Query OK, 0 rows affected (0.07 sec)
Then you can log in normally.

How to solve the error of PHP connection to mysql8

PHP version is 5.6. An error is reported when connecting to mysql8.0, but it is normal to connect to other versions before mysql8

The reason may be that mysql8 uses different password authentication methods by default, and mysql8.0 uses caching by default_sha2_Password, but previous versions used mysql_native_password

Solution:

Modify the/etc/my.cnf file

Find default authentication plugin = MySQL_native_Password line

Cancel the # number in front and restart mysql. MySQL will be used by default_native_Password, and then use the previous PHP script to test the connection to MySQL

As follows. The root user marked by the red arrow can connect normally