MySQL出现:ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)问题解决

本文mysql的安装环境为win7 64位,mysql版本为MySQL5.7

问题描述:在命令行输入 mysql -u root -p 登录mysql,返回”Can't connect to MySQL server on localhost (10061)”错误

意思大概就是:无法连接到“本地主机”(10061)上的MySQL服务器

MySQL出现:ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)问题解决

  1、首先安装mysqld服务器,输入命令:mysqld --install

MySQL出现:ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)问题解决

现在就安装好了

2、接下来就是启动服务器了,输入命令:net start mysql

MySQL出现:ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)问题解决

本来我以为跟别人一样在这个地方就启动了,结果事与愿违,于是又找了很久,别走神!看下面!!

3、输入命令:mysqld --initialize-insecure

完了再次输入:net start mysql

MySQL出现:ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)问题解决

MySQL出现:ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)问题解决

你没看错,启动成功了。嗯,有些人可能可以正常使用了,但我就是这么悲催。

4、又给我出了个问题:Access denied for user 'root'@'localhost' (using password: YES)

MySQL出现:ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)问题解决

 5、 安装的时候设了密码,为什么不用密码就可以登录

MySQL出现:ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)问题解决

 6、改密码,进入mysql数据库:use mysql

MySQL出现:ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)问题解决

 ①update mysql.user set authentication_string=password('123456') where user='root' ;

 ②(5.7.11以前) > update user set password=password("123456") where user="root";

 ③(5.7.11 或者以后)> update user set authentication_string=password("123456") where user="root";

在这儿我是用的是:

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';     改完密码刷新一下:flush privileges;

MySQL出现:ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)问题解决

7、退出重新登录

MySQL出现:ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)问题解决

 

上一篇:mysql 8.0.23 启动报错 ERROR 2002 (HY000): Can't connect to local MySQL server through socket '


下一篇:Android通过chroot使用Linux运行mariadb无法启动问题