linux下安裝mysql

1.安裝過程:debuger-info-->shard-->client-->server

啓動:service mysql start

關閉:service mysql stop

重啓:service mysql restart

2.關閉linux防火牆:services iptables stop

打開防火牆:servies iptables start

查看防火牆:services iptables status

iptables報錯:使用service iptables stop 顯示not loaded

解決方法:

centos從7開始默認用的是firewalld,這個是基於iptables的,雖然有iptables的核心,但是iptables的服務是沒安裝的。所以你只要停止firewalld服務即可: 
sudo systemctl stop firewalld.service && sudo systemctl disable firewalld.service

如果你要改用iptables的話,需要安裝iptables服務: 
sudo yum install iptables-services 
sudo systemctl enable iptables && sudo systemctl enable ip6tables 
sudo systemctl start iptables && sudo systemctl start ip6tables

3.遠程連接報錯:原因未授權

GRANT ALL PRIVILEGES ON *.* TO root @'%' IDENTIFIED BY "自己的密碼";

% 表示所有的IP都能訪問,也可以修改爲專屬的

4.用戶名密碼錯誤:

mysq -u root -p  回車

空密碼回車

進入mysql命令行:

use mysql;

update user set password=password("你的新密碼") where user="root";

如果修改失敗:ERROR 1062 (23000): Duplicate entry '%-root' for key 'PRIMARY' 

可以直接查看:select host,user from user where user='root';

5..重啓mysql

 

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章