方法一:
在管理--》服務(wù)中啟動 MySQL 服務(wù)
下面的方式?jīng)]有試,也記錄一下
問題描述:在命令行輸入 mysql -u root -p 登錄mysql,返回”Can't connect to MySQL server on localhost (10061)”錯誤

問題原因:查到問題原因是mysql沒有啟動。
解決方法:1、將mysql加入到Windows的服務(wù)中。切換到mysql安裝目錄下的bin文件夾,命令行運行"mysqld --install"
1 C:\Program Files\MySQL\MySQL Server 5.7\bin> mysqld --install
2 Service successfully installed.
此時若使用“net start mysql”成功啟動msyql,則無須執(zhí)行下面步驟
2、初始化mysql數(shù)據(jù)庫,輸入“mysqld --initialize --user=root --console”。下面紅色文字為初始化后的root 密碼,最后一部分是密碼: u).ig.Gd.7hW
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,通過“set password=password('123456')”修改密碼。此處將root密碼設(shè)置為123456文章來源:http://www.zghlxwxcb.cn/news/detail-549614.html
mysql> set password=password('123456');
Query OK, 0 rows affected, 1 warning (0.00 sec)
https://www.cnblogs.com/technologylife/p/6010205.html文章來源地址http://www.zghlxwxcb.cn/news/detail-549614.html
到了這里,關(guān)于MySQL問題--Can‘t connect to MySQL server on localhost (10061)解決方法的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!