ubuntu16 0 4設定mysql遠端訪問

2021-08-21 13:26:05 字數 843 閱讀 9184

ubuntu16.0.4設定mysql遠端訪問

一般程式開發過程為了方便除錯中會需要遠端訪問資料庫,而mysql本身是預設只能訪問localhost,所以需要做一些設定。

1.首先,需要修改mysql的配置,執行

vi /etc/mysql/mysql.conf.d/mysqld.cnf
注釋掉如下內容:

2.最簡單粗暴的辦法就是允許所有位址都可以通過root賬號遠端連線

msyql -u root -p

grant all on *.* to root@'%' identified by '123' with grant option;

flush privileges;

*.*:表示mysql下的所有資料庫和表

%:遠端連線時的密碼

3.重啟mysql:

/etc/init.d/mysql restart
或者,相對安全一點的辦法就是在第二步的時候新建乙個使用者,然後對遠端訪問只開放需要的資料庫表

# 建立使用者

create user 'username'@'%' identified by 'password';

#授權grant all on test.* to username@'%' identified by '123' with grant option;

#重新整理許可權

flush privileges;

ubuntu16 04預設python設定

ubuntu16.04預設的pthon版本是2.7,如果想要用python3可以直接用python3 要執行的檔名,可是這樣不方便。將python3設定為預設版本 其實就是設定優先順序 sudo update alternatives install usr bin python python us...

ubuntu16 04自動設定行號

第一步 安裝vim 命令為 sudo apt get install vim 第二步 更改vim的配置檔案etc vim命令為 1 cd etc vim 2 sudo gedit vimrc 第三步 在vimrc最後令起一行插入下面內容 syntax on set tabstop 4 set shi...

ubuntu16 0 4 設定固定ip位址

由於ubuntu重啟之後,ip很容易改變,可以用以下方式固定ip位址 1.設定ip位址 vi etc network inte ce the loopback network inte ce auto lo iface lo inet loopback the primary network int...