Mysql在Ubuntu上的快速安裝使用
阿新 • • 發佈:2019-04-10
安裝:
sudo apt update
sudo apt install mysql-server
安裝過程會需要輸入密碼。
登入:
mysql -u root -p
允許遠端登入:
直接啟動,用別臺機器遠端登入會有2003的錯誤,允許遠端登入做了如下嘗試:
1)登入之後,嘗試修改root的host為%
show databases;
use mysql;
select user, host from user;
update user set host = "%" where user = "root";
由於存在多個root user,導致更新並不成功。(如果僅有一個root user,這種方式可以成功)
2)更新許可權:
grant all privileges on *.* to "root"@"%" identified by "root" with grant option;
flush privileges;
但是遠端訪問還是報了2003的錯誤。
3)修改配置,重啟mysql:
找到mysql的配置檔案/etc/mysql/my.cnf, 將"bind-address = 127.0.0.1"註釋掉
# # Instead of skip-networking the default is now to listen only on # localhost which is more compatible and is not less secure. #bind-address = 127.0.0.1
重啟mysql服務
sudo service mysql restart
經過這麼多嘗試之後,終於可