mysql服务无法启动,ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)解决办法

很长时间没有用数据库了,之前在电脑上安装了mysql,但是许久不用,最近用起来却是问题多多,提示无法启动服务器, 却没有报任何错误。使用net start mysql 启动服务提示如下图:这里写图片描述
使用mysql –console命令查看错误信息。如下:

D:\Program Files (x86)\mysql\bin>mysqld –console
2018-01-27T07:04:33.136066Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use –explicit_defaults_for_timestamp server option (see documentation for more details).
2018-01-27T07:04:33.136066Z 0 [Warning] ‘NO_ZERO_DATE’, ‘NO_ZERO_IN_DATE’ and ‘ERROR_FOR_DIVISION_BY_ZERO’ sql modes should be used with strict mode. They will be merged with strict mode in a future release.
2018-01-27T07:04:33.136066Z 0 [Warning] ‘NO_AUTO_CREATE_USER’ sql mode was not set.
2018-01-27T07:04:33.136566Z 0 [Note] –secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
2018-01-27T07:04:33.137072Z 0 [Note] mysqld (mysqld 5.7.16) starting as process 8304 …
2018-01-27T07:04:33.153080Z 0 [Note] InnoDB: Mutexes and rw_locks use Windows interlocked functions
2018-01-27T07:04:33.155586Z 0 [Note] InnoDB: Uses event mutexes
2018-01-27T07:04:33.158582Z 0 [Note] InnoDB: _mm_lfence() and _mm_sfence() are used for memory barrier
2018-01-27T07:04:33.162091Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3
2018-01-27T07:04:33.166087Z 0 [Note] InnoDB: Number of pools: 1
2018-01-27T07:04:33.168093Z 0 [Note] InnoDB: Not using CPU crc32 instructions
2018-01-27T07:04:33.178617Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2018-01-27T07:04:33.196880Z 0 [Note] InnoDB: Completed initialization of buffer pool
2018-01-27T07:04:33.301294Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2018-01-27T07:04:33.398212Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2018-01-27T07:04:33.400215Z 0 [Note] InnoDB: Setting file ‘.\ibtmp1’ size to 12 MB. Physically writing the file full; Please wait …
2018-01-27T07:04:33.762696Z 0 [Note] InnoDB: File ‘.\ibtmp1’ size is now 12 MB.
2018-01-27T07:04:33.768670Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
2018-01-27T07:04:33.769649Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2018-01-27T07:04:33.776647Z 0 [Note] InnoDB: Waiting for purge to start
2018-01-27T07:04:33.863016Z 0 [Note] InnoDB: 5.7.16 started; log sequence number 1210037
2018-01-27T07:04:33.871522Z 0 [Note] Plugin ‘FEDERATED’ is disabled.
2018-01-27T07:04:33.872524Z 0 [Note] InnoDB: Loading buffer pool(s) from D:\Program Files (x86)\mysql\data\ib_buffer_pool
mysqld: Table ‘mysql.plugin’ doesn’t exist
2018-01-27T07:04:33.879708Z 0 [ERROR] Can’t open the mysql.plugin table. Please run mysql_upgrade to create it.
2018-01-27T07:04:33.883719Z 0 [Warning] Gtid table is not ready to be used. Table ‘mysql.gtid_executed’ cannot be opened.
2018-01-27T07:04:33.884219Z 0 [Note] InnoDB: Buffer pool(s) load completed at 180127 15:04:33
2018-01-27T07:04:33.884716Z 0 [Warning] Failed to set up SSL because of the following SSL library error: SSL context is not usable without certificate and private key
2018-01-27T07:04:33.891085Z 0 [Note] Server hostname (bind-address): ‘127.0.0.1’; port: 3306
2018-01-27T07:04:33.896110Z 0 [Note] - ‘127.0.0.1’ resolves to ‘127.0.0.1’;
2018-01-27T07:04:33.899095Z 0 [Note] Server socket created on IP: ‘127.0.0.1’.
2018-01-27T07:04:33.901596Z 0 [Warning] Failed to open optimizer cost constant tables

2018-01-27T07:04:33.932264Z 0 [ERROR] Fatal error: Can’t open and lock privilege tables: Table ‘mysql.user’ doesn’t exist
2018-01-27T07:04:33.934266Z 0 [ERROR] Aborting

2018-01-27T07:04:33.936266Z 0 [Note] Binlog end
2018-01-27T07:04:33.938769Z 0 [Note] Shutting down plugin ‘ngram’
2018-01-27T07:04:33.941273Z 0 [Note] Shutting down plugin ‘partition’
2018-01-27T07:04:33.944295Z 0 [Note] Shutting down plugin ‘BLACKHOLE’
2018-01-27T07:04:33.947699Z 0 [Note] Shutting down plugin ‘ARCHIVE’
2018-01-27T07:04:33.952246Z 0 [Note] Shutting down plugin ‘PERFORMANCE_SCHEMA’
2018-01-27T07:04:33.957152Z 0 [Note] Shutting down plugin ‘MRG_MYISAM’
2018-01-27T07:04:33.959657Z 0 [Note] Shutting down plugin ‘MyISAM’
2018-01-27T07:04:33.961655Z 0 [Note] Shutting down plugin ‘INNODB_SYS_VIRTUAL’
2018-01-27T07:04:33.963653Z 0 [Note] Shutting down plugin ‘INNODB_SYS_DATAFILES’
2018-01-27T07:04:33.967396Z 0 [Note] Shutting down plugin ‘INNODB_SYS_TABLESPACES’
2018-01-27T07:04:33.969398Z 0 [Note] Shutting down plugin ‘INNODB_SYS_FOREIGN_COLS’
2018-01-27T07:04:33.972404Z 0 [Note] Shutting down plugin ‘INNODB_SYS_FOREIGN’
2018-01-27T07:04:33.974905Z 0 [Note] Shutting down plugin ‘INNODB_SYS_FIELDS’
2018-01-27T07:04:33.978926Z 0 [Note] Shutting down plugin ‘INNODB_SYS_COLUMNS’
2018-01-27T07:04:33.980927Z 0 [Note] Shutting down plugin ‘INNODB_SYS_INDEXES’
2018-01-27T07:04:33.983910Z 0 [Note] Shutting down plugin ‘INNODB_SYS_TABLESTATS’
2018-01-27T07:04:33.985910Z 0 [Note] Shutting down plugin ‘INNODB_SYS_TABLES’
2018-01-27T07:04:33.990736Z 0 [Note] Shutting down plugin ‘INNODB_FT_INDEX_TABLE’
2018-01-27T07:04:33.992949Z 0 [Note] Shutting down plugin ‘INNODB_FT_INDEX_CACHE’
2018-01-27T07:04:33.995451Z 0 [Note] Shutting down plugin ‘INNODB_FT_CONFIG’
2018-01-27T07:04:33.997966Z 0 [Note] Shutting down plugin ‘INNODB_FT_BEING_DELETED’
2018-01-27T07:04:34.001545Z 0 [Note] Shutting down plugin ‘INNODB_FT_DELETED’
2018-01-27T07:04:34.003521Z 0 [Note] Shutting down plugin ‘INNODB_FT_DEFAULT_STOPWORD’
2018-01-27T07:04:34.007029Z 0 [Note] Shutting down plugin ‘INNODB_METRICS’
2018-01-27T07:04:34.010030Z 0 [Note] Shutting down plugin ‘INNODB_TEMP_TABLE_INFO’
2018-01-27T07:04:34.013049Z 0 [Note] Shutting down plugin ‘INNODB_BUFFER_POOL_STATS’
2018-01-27T07:04:34.015051Z 0 [Note] Shutting down plugin ‘INNODB_BUFFER_PAGE_LRU’
2018-01-27T07:04:34.017940Z 0 [Note] Shutting down plugin ‘INNODB_BUFFER_PAGE’
2018-01-27T07:04:34.019978Z 0 [Note] Shutting down plugin ‘INNODB_CMP_PER_INDEX_RESET’
2018-01-27T07:04:34.024836Z 0 [Note] Shutting down plugin ‘INNODB_CMP_PER_INDEX’
2018-01-27T07:04:34.026841Z 0 [Note] Shutting down plugin ‘INNODB_CMPMEM_RESET’
2018-01-27T07:04:34.029461Z 0 [Note] Shutting down plugin ‘INNODB_CMPMEM’
2018-01-27T07:04:34.031472Z 0 [Note] Shutting down plugin ‘INNODB_CMP_RESET’
2018-01-27T07:04:34.034970Z 0 [Note] Shutting down plugin ‘INNODB_CMP’
2018-01-27T07:04:34.036992Z 0 [Note] Shutting down plugin ‘INNODB_LOCK_WAITS’
2018-01-27T07:04:34.040473Z 0 [Note] Shutting down plugin ‘INNODB_LOCKS’
2018-01-27T07:04:34.045402Z 0 [Note] Shutting down plugin ‘INNODB_TRX’
2018-01-27T07:04:34.047893Z 0 [Note] Shutting down plugin ‘InnoDB’
2018-01-27T07:04:34.050219Z 0 [Note] InnoDB: FTS optimize thread exiting.
2018-01-27T07:04:34.052437Z 0 [Note] InnoDB: Starting shutdown…
2018-01-27T07:04:34.157460Z 0 [Note] InnoDB: Dumping buffer pool(s) to D:\Program Files (x86)\mysql\data\ib_buffer_pool
2018-01-27T07:04:34.162963Z 0 [Note] InnoDB: Buffer pool(s) dump completed at 180127 15:04:34
2018-01-27T07:04:35.213788Z 0 [Note] InnoDB: Shutdown completed; log sequence number 1210056
2018-01-27T07:04:35.215789Z 0 [Note] InnoDB: Removed temporary tablespace data file: “ibtmp1”
2018-01-27T07:04:35.220130Z 0 [Note] Shutting down plugin ‘MEMORY’
2018-01-27T07:04:35.224125Z 0 [Note] Shutting down plugin ‘CSV’
2018-01-27T07:04:35.229127Z 0 [Note] Shutting down plugin ‘sha256_password’
2018-01-27T07:04:35.232630Z 0 [Note] Shutting down plugin ‘mysql_native_password’
2018-01-27T07:04:35.240522Z 0 [Note] Shutting down plugin ‘binlog’
2018-01-27T07:04:35.246009Z 0 [Note] mysqld: Shutdown complete
经过一天的查找最终发现是因为mysql安装目录下的data文件夹中的数据有问题,定位到问题了,修改起来就不难啦!
我们可以使用mysql –initialize命令让mysql自己初始化data文件夹,这样就不会有问题了。
但是注意执行mysql –initialize命令前应该注释掉安装目录下my.ini中datadir一行的内容,并删除掉原先的data目录,在执行就好了。
再次启动mysql就会成功啦!
希望能够帮助大家^-^

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
ERROR 2003 HY000: Can't connect to MySQL server on 'localhost:3306' 10061 是一个MySQL数据库连接错误。这个错误表示无法连接到MySQL服务器。通常,这个错误是由于以下几个原因之一引起的: 1. MySQL服务器没有正确启动。 2. MySQL服务器的端口号不正确。 3. 防火墙或网络设置阻止了与MySQL服务器的连接。 4. MySQL服务器配置文件中的配置错误。 对于解决这个错误,你可以尝试以下几个步骤: 1. 确保MySQL服务器已经正确启动。你可以尝试通过命令行或者服务管理工具来启动MySQL服务器。 2. 检查MySQL服务器的端口号是否正确。默认情况下,MySQL服务器使用3306端口。如果你的MySQL服务器使用了其他端口,你需要相应地进行配置。 3. 检查防火墙或网络设置,确保允许与MySQL服务器的连接。你可以尝试暂时关闭防火墙来验证是否是防火墙导致的问题。 4. 检查MySQL服务器的配置文件,确保配置正确。特别是检查bind-address选项是否正确设置为允许连接的IP地址。 如果你尝试了以上步骤仍然无法解决问题,你可能需要进一步检查网络配置、MySQL服务器日志以及相关的错误信息来找出问题的具体原因。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [ERROR 2003 (HY000) Can‘t connect to MySQL server on ‘localhost3306‘ (10061)解决办法](https://blog.csdn.net/m0_67402236/article/details/126012580)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *2* [解决MySQL报错ERROR 2003 (HY000): Can‘t connect to MySQL server on ‘localhost:3306‘ (10061)](https://blog.csdn.net/wangpaiblog/article/details/121667877)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值