MySQL问题记录--Can't connect to MySQL server on localhost (10061)解决方法
2022/1/3 19:12:41
本文主要是介绍MySQL问题记录--Can't connect to MySQL server on localhost (10061)解决方法,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
MySQL问题记录--Can't connect to MySQL server on localhost (10061)解决方法
本文mysql的安装环境为win10 64位,mysql版本为MySQL5.7
问题描述:在命令行输入 mysql -u root -p 登录mysql,返回”Can't connect to MySQL server on localhost (10061)”错误
问题原因:在一番谷歌后,查到问题原因是mysql没有启动。
解决方法:1、将mysql加入到Windows的服务中。切换到mysql安装目录下的bin文件夹,命令行运行"mysqld --install"
1 C:\Program Files\MySQL\MySQL Server 5.7\bin> mysqld --install 2 Service successfully installed.
此时若使用“net start mysql”成功启动msyql,则无须执行下面步骤
2、初始化mysql数据库,输入“mysqld --initialize --user=root --console”。下面红色文字为初始化后的root 密码
C:\Program Files\MySQL\MySQL Server 5.7\bin>mysqld --initialize --user=root --console 2016-10-29T01:35:44.309833Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see doc umentation for more details). 2016-10-29T01:35:46.659968Z 0 [Warning] InnoDB: New log files created, LSN=45790 2016-10-29T01:35:47.154996Z 0 [Warning] InnoDB: Creating foreign key constraintsystem tables. 2016-10-29T01:35:47.362008Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 043563f4-9d78-11e6-a8c8-606dc79c383c. 2016-10-29T01:35:47.388009Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened. 2016-10-29T01:35:47.401010Z 1 [Note] A temporary password is generated for root@localhost: u).ig.Gd.7hW
3、此时使用“net start mysql”成功启动msyql
4、使用生成的密码登录mysql,执行select * from mysql.user
针对这个错误You must reset your password using ALTER USER statement before executing this statement.
然后执行alter user user() identified by 'XXXX'; XXXX代表密码
出现
mysql> alter user user() identified by '2021';
Query OK, 0 rows affected (0.09 sec)
成功
这篇关于MySQL问题记录--Can't connect to MySQL server on localhost (10061)解决方法的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-12-07MySQL读写分离入门:轻松掌握数据库读写分离技术
- 2024-12-07MySQL读写分离入门教程
- 2024-12-07MySQL分库分表入门详解
- 2024-12-07MySQL分库分表入门指南
- 2024-12-07MySQL慢查询入门:快速掌握性能优化技巧
- 2024-12-07MySQL入门:新手必读的简单教程
- 2024-12-07MySQL入门:从零开始学习MySQL数据库
- 2024-12-07MySQL索引入门:新手快速掌握MySQL索引技巧
- 2024-12-06BinLog学习:MySQL数据库BinLog入门教程
- 2024-12-06Binlog学习:MySQL数据库的日志管理入门教程