本文mysql的安裝環境為win7 64位,mysql版本為MySQL5.7
問題描述:在命令行輸入 mysql -u root -p 登錄mysql,返回”Can't connect to MySQL server on localhost (10061)”錯誤
意思大概就是:無法連接到“本地主機”(10061)上的MySQL服務器
1、首先安裝mysqld服務器,輸入命令:mysqld --install
現在就安裝好了
2、接下來就是啟動服務器了,輸入命令:net start mysql
本來我以為跟別人一樣在這個地方就啟動了,結果事與願違,於是又找了很久,別走神!看下面!!
3、輸入命令:mysqld --initialize-insecure
完了再次輸入:net start mysql
你沒看錯,啟動成功了。嗯,有些人可能可以正常使用了,但我就是這么悲催。
4、又給我出了個問題:Access denied for user 'root'@'localhost' (using password: YES)
5、 安裝的時候設了密碼,為什么不用密碼就可以登錄
6、改密碼,進入mysql數據庫:use mysql
①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;
7、退出重新登錄