1. 程式人生 > 其它 >linux中mariadb用navicat遠端連線

linux中mariadb用navicat遠端連線

在Linux中建立資料庫並且遠端圖形化工具連線

  • 安裝資料庫
   [root@node1 ~]# yum install mariadb-server -y
   #這裡我使用的mariadb  其他資料庫也可以
  • 初始化資料庫
[root@node1 ~]# systemctl start mariadb.service
[root@node1 ~]# mysql_secure_installation
Enter current password for root (enter for none): 當前root使用者密碼為空,所以直接 敲回車 OK, successfully used password, moving on... Set root password? [Y/n] y 設定root密碼 New password: Re-enter new password: Password updated successfully! Remove anonymous users? [Y/n] y 刪除匿名使用者 ... Success! Disallow root login remotely? [Y/n] n #禁止root遠端登入 ... Success! Remove test database and access to it? [Y/n] y 刪除test資料庫 - Dropping test database... ... Success! - Removing privileges on test database... ... Success! Reload privilege tables now? [Y/n] y 重新整理授權表,讓初始化生效 ... Success! 
  • 檢視資料庫狀態
[root@node1 ~]# systemctl status mariadb.service
# running  執行
   ss -tnl 檢視埠號
  • 然後進入資料庫
      #mysql -uroot -p

首先進入mysql資料庫,然後輸入下面兩個命令:

grant all privileges on *.* to 'root'@'%' identified by 'password';
flush privileges;

第一個*是資料庫,可以改成允許訪問的資料庫名稱

第二個 是資料庫的表名稱,代表允許訪問任意的表

root代表遠端登入使用的使用者名稱,可以自定義

%代表允許任意ip登入,如果你想指定特定的IP,可以把%替換掉就可以了

password代表遠端登入時使用的密碼,可以自定義

flush privileges;這是讓許可權立即生效

  • 然後本地遠端連線
mysql -h 伺服器ip地址 -P 3306 -u root -p

總結:以上這篇檔案就是我對 在Linux中遠端連線資料庫的認識,歡迎大家點評