Mysql安装问题汇总
解決Navicat連接不上MySql服務器報錯:Client does not support authentication protocol requested by server; consider upgrading MySQL client
1.問題原因
2.解決問題
1.問題原因
通過相關問題查閱,發現是由于navicat版本的問題造成連接失敗。mysql8 之前的版本中加密規則是mysql_native_password,而在mysql8之后,加密規則是caching_sha2_password
MySql查看版本號-1
LITING:~ liting$ mysql -uroot -p ? ?// 進入mysql
Enter password: ?//輸入mysql密碼,如下提示表示登錄成功
Welcome to the MySQL monitor. ?Commands end with ; or \g.
Your MySQL connection id is 24
Server version: 8.0.14 MySQL Community Server - GPL
Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>?
MySql查看版本號-2(可以進入mysql后通過mysql命令查看)
mysql> select version();
+-----------+
| version() |
+-----------+
| 8.0.14 ? ?|
+-----------+
1 row in set (0.00 sec)
2.解決問題
1.進入mysql
LITING:~ liting$ mysql -uroot -p
Enter password: ?// mysql密碼
Welcome to the MySQL monitor. ?Commands end with ; or \g.
Your MySQL connection id is 26
Server version: 8.0.14 MySQL Community Server - GPL
Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
2.輸入命令修改加密規則
1.ALTER USER ‘root’@‘localhost’ IDENTIFIED BY ‘password’ PASSWORD EXPIRE NEVER;
password替換為mysql連接密碼
ALTER USER 'root'@'localhost' IDENTIFIED BY '12345678' PASSWORD EXPIRE NEVER;
1
2.ALTER USER ‘root’@‘localhost’ IDENTIFIED WITH mysql_native_password BY ‘password’;
password為修改的新密碼。
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
1
3.刷新權限,使修改生效。
FLUSH PRIVILEGES;?
1
4.查看表中相關信息,確認修改是否真正生效
mysql> use mysql; ?//先使用命令 use mysql
Database changed
mysql> select user,host,plugin from user where user='root'; // 在輸入該命令
+------+-----------+-----------------------+?
| user | host ? ? ?| plugin ? ? ? ? ? ? ? ?|
+------+-----------+-----------------------+
| root | localhost | mysql_native_password |
+------+-----------+-----------------------+
1 row in set (0.00 sec)
如上,密碼校驗規則已經修改成功
//******
最近遇到了一件非常棘手的問題,用Navicat遠程連接數據庫居然連接不到,真是頭都大了。
網上查閱了一下原因,原來是沒有開通遠程權限,好吧,下面我就來回憶一下自己怎么處理這問題的!
大家都知道,用Navicat連接數據庫一般是這樣連得:
問題整理以及解決辦法
錯誤一:
錯誤原因:
本地IP(xxx.xxx.xxx.xxx)沒有訪問遠程數據庫的權限。于是下面開啟本地IP(xxx.xxx.xxx.xxx)對遠程mysql數據庫的訪問權限。
解決辦法:
1.首先遠程連接進入服務器,在cmd中輸入mysql -u root -p,然后回車,輸入密碼后回車進入mysql命令行。
2.輸入use mysql;
3.輸入select user,password,host from user;
可以看到host中只有localhost主機。我們需要將xxx.xxx.xxx.xxx也添加到這里才對。
4.添加方法如下:
輸入
grant all privileges on *.* to root@”xxx.xxx.xxx.xxx” identified by “密碼”;
或者 ?GRANT ALL PRIVILEGES ON *.* TO ‘root’@’xxx.xxx.xxx.xxx’ IDENTIFIED BY ‘123456’ WITH GRANT OPTION;
這相當于是給IP-xxx.xxx.xxx.xxx賦予了所有的權限,包括遠程訪問權限。
然后再輸入
flush privileges;
這相當于是重新加載一下mysql權限,這一步必須有。
5.再次輸入select user,password,host from user;
可以看到host中已經有了新加的IP。
6.現在再次用Navicat for MySQl訪問遠程mysql數據庫,已經能正常打開了。
問題解決。
7.如果還是連接不到,那是不是 MySQL Server 綁定了本地地址,打開 /etc/mysql/my.cnf,
找到:bind-address = 127.0.0.1
去除 IP 地址綁定,把它改為:bind-address = 0.0.0.0
然后重啟 MySQL Server:/etc/init.d/mysql restart
錯誤二:
ERROR 2003 (HY000): Can’t connect to MySQL server on ‘hostxxxxx’ (10061)
錯誤原因:
mysqld數據庫服務沒有啟動。
解決辦法:
檢查 :在windows 的任務管理器,或者 unix/linux 下 ps -aux | grep mysql 看一下。確認服務已經啟動。
處理 :啟動mysqld 服務
錯誤三:
防火墻開啟了
解決方法:
防火墻需要允許3306端口連接。
//*******
MySQL在命令行可以連接上,但是用Navicat 連接不上
起因
今天大蝦在學數據庫的時候,發現老師的數據庫用Navicat一下就連接上了,但是大蝦的就是連接不上,而且報錯是提示密碼有問題。但是在命令行,數據庫是可以正常連接的。這就是說數據庫本身是沒有問題的。然后大蝦今天的奇幻冒險就開始了。就是要解決這個問題
解決
經過多方查找資料,最后發現是mysql8 的加密方式有了變化。下面是Navicat連接數據庫的具體操作:
①、Windows+r 吊起命令行窗口
②、cmd 回車,進入命令行窗口
③、輸入mysql -u root -p (root 是mysql數據庫的用戶名,我的測試用的數據庫名稱是mysql),并輸入mysql的密碼
④、更改加密方式:輸入
ALTER USER ‘root’@‘localhost’ IDENTIFIED BY ‘password’ PASSWORD EXPIRE NEVER; #password 是你的數據庫密碼
⑤、更改密碼:輸入
ALTER USER ‘root’@‘localhost’ IDENTIFIED WITH mysql_native_password BY ‘password’; # password是你數據庫的密碼
(第二行的query是輸入內容以后,回車返回的結果)
⑥、刷新一下,輸入:
FLUSH PRIVILEGES;
(第二行的query是輸入內容以后,回車返回的結果)
注意:三個語句缺一不可,三個語句后方都是有分號的,必須要有的
?
創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎總結
以上是生活随笔為你收集整理的Mysql安装问题汇总的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Mysql数据库常用指令
- 下一篇: springCloud - 第13篇 -