MySQL問題記錄--Can't connect to MySQL server on localhost (10061)解決方案

來源:互聯網
上載者:User

標籤:images   技術分享   exist   執行   his   sum   font   host   百度   

本文mysql的安裝環境為win7 64位,mysql版本為MySQL5.7

 

問題描述:在命令列輸入 mysql -u root -p 登入mysql,返回”Can‘t connect to MySQL server on localhost (10061)”錯誤

 

問題原因:在一番Google、百度後,查到問題原因是mysql沒有啟動。

 

解決方案:1、將mysql加入到Windows的服務中。切換到mysql安裝目錄下的bin檔案夾,命令列運行"mysqld --install"

1 C:\Program Files\MySQL\MySQL Server 5.7\bin> mysqld --install2 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 --console2016-10-29T01:35:44.309833Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).2016-10-29T01:35:46.659968Z 0 [Warning] InnoDB: New log files created, LSN=457902016-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. Generatinga 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 [email protected]: u).ig.Gd.7hW

      3、此時使用“net start mysql”成功啟動msyql

    4、使用產生的密碼登入mysql,通過“set password=password(‘123456‘)”修改密碼。此處將root密碼設定為123456

mysql> set password=password(‘123456‘);Query OK, 0 rows affected, 1 warning (0.00 sec)

 

MySQL問題記錄--Can't connect to MySQL server on localhost (10061)解決方案

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.