您好,登錄后才能下訂單哦!
Proxy Server IP: 10.0.0.10
Ubuntu Server IP: 10.0.0.11
Window PC IP: 10.0.0.12
?
一、登錄Ubuntu服務器,或者使用Putty遠程登錄。
Last login: Mon Dec 30 04:15:26 2019 from 10.0.0.12
二、查看IP,DNS設置,確認可以聯網,可以聯網的直接跳到第四步。
paul@ubuntu1804:~$ ping www.163.com
ping: www.163.com: Temporary failure in name resolution
我這里因為在虛擬機網絡10.0.0.0/24是通過代理服務器上網,首先得在Ubuntu里設置代理,加上配置文件的后面三條。
paul@ubuntu1804:~$ sudo vim /etc/environment
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
?
http_proxy=http://10.0.0.10:3128/
https_proxy=https://10.0.0.10:3128/
no_proxy="localhost,127.0.0.1,::1"
然后查看系統是否安裝了wget。
paul@ubuntu1804:~$ sudo dpkg -s wget
Package: wget
Status: install ok installed
查詢已安裝,否則使用sudo apt -y install wget安裝, 然后用wget測試是否能連接互聯網
paul@ubuntu1804:~$ sudo wget yahoo.com
URL transformed to HTTPS due to an HSTS policy
--2019-12-30 06:01:28--? https://yahoo.com/
Connecting to 10.0.0.10:3128... connected.
Proxy request sent, awaiting response... 301 Moved Permanently
Location: https://www.yahoo.com/ [following]
--2019-12-30 06:01:29--? https://www.yahoo.com/
Connecting to 10.0.0.10:3128... connected.
Proxy request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: ‘index.html’
?
index.html????? [????? <=>??????????????????? ] 334.26K? 59.0KB/s??? in 6.0s
?
2019-12-30 06:01:35 (55.4 KB/s) - ‘index.html’ saved [342281]
paul@ubuntu1804:~$ ls
index.html
三、可以只修改apt的代理,參考文末的寫法。
paul@ubuntu1804:~$ cd /etc/apt/apt.conf.d/
paul@ubuntu1804:/etc/apt/apt.conf.d$ sudo touch proxy.conf
[sudo] password for paul:
paul@ubuntu1804:/etc/apt/apt.conf.d$ sudo vim proxy.conf
Acquire::http::Proxy "http://10.0.0.1:3128/";
Acquire::https::Proxy "http://10.0.0.1:3128/";
四、現在準備安裝數據庫服務器,首先查詢是否有mariadb的安裝包。
paul@ubuntu1804:/etc/apt/apt.conf.d$ sudo apt search mariadb
Sorting... Done
Full Text Search... Done
......
mariadb-server/bionic-updates,bionic-security 1:10.1.43-0ubuntu0.18.04.1 all
? MariaDB database server (metapackage depending on the latest version)
?
mariadb-server-10.1/bionic-updates,bionic-security 1:10.1.43-0ubuntu0.18.04.1 amd64
? MariaDB database server binaries
......
我們看到有mariadb-server和mariadb-server-10.1,開始安裝mariadb-server。
paul@ubuntu1804:/etc/apt/apt.conf.d$ sudo apt -y install mariadb-server
……
五、安裝完成,用默認的root賬戶登錄數據庫,初始默認沒有密碼。
paul@ubuntu1804:~$ sudo mysql -u root
Welcome to the MariaDB monitor.? Commands end with ; or \g.
Your MariaDB connection id is 41
Server version: 10.1.43-MariaDB-0ubuntu0.18.04.1 Ubuntu 18.04
?
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
?
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
查看一下有哪些數據庫。
MariaDB [(none)]> show databases;
+--------------------+
| Database?????????? |
+--------------------+
| information_schema ?|
| mysql??????????? ?????????????????|
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)
六、現在我們創建一個數據庫demo。
MariaDB [(none)]> create database demo;
Query OK, 1 row affected (0.01 sec)
?
MariaDB [(none)]> show databases;
+--------------------+
| Database?????????? |
+--------------------+
| demo?????????????? |
| information_schema |
| mysql????????????? |
| performance_schema |
+--------------------+
4 rows in set (0.00 sec)
然后建立一個用來管理demo數據庫的賬戶,允許它在10.0.0.0網絡遠程連接,密碼為Admin@123。
MariaDB [(none)]> GRANT ALL ON demo.* to sqladm@'10.0.0.%' IDENTIFIED BY 'Admin@123' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)
刷新權限。
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
退出數據庫root賬戶。
MariaDB [(none)]> exit
Bye
七、然后我們在Win10電腦安裝MySQL Workbench用圖形管理工具遠程管理此數據庫。安裝完成以后用創建的用戶名和密碼嘗試連接服務器10.0.0.11上的數據庫,發現無法連接。
查看mariaDB的服務配置文件,里面有一條bind-address = 127.0.0.1,意思是只允許本機連接,我們注釋掉這條。
paul@ubuntu1804:~$ cd /etc/mysql/mariadb.conf.d/
paul@ubuntu1804:/etc/mysql/mariadb.conf.d$ sudo vim 50-server.cnf
……
# bind-address = 127.0.0.1
然后重啟mariadb服務,這個服務名字不是mariadb,而是mysqld,否則會提示沒有服務。
paul@ubuntu1804:/etc/mysql/mariadb.conf.d$ systemctl status mysqld
?
八、再次嘗試連接,仍然不行,我們查看ubuntu 1804的防火墻,它使用的不是iptables和firewalld,而是ufw,我們停止ufw服務。
如果使用的Redhat系7.0版以上的防火墻為firewalld,其他版本請自行查詢。
注意:停止防火墻只為測試,生產服務器測試成功后需修改防火墻規則允許MySQL遠程連接,并開啟防火墻。
paul@ubuntu1804:/etc/mysql/mariadb.conf.d$ systemctl status ufw
● ufw.service - Uncomplicated firewall
?? Loaded: loaded (/lib/systemd/system/ufw.service; enabled; vendor preset: enabled)
?? Active: active (exited) since Mon 2019-12-30 05:39:26 UTC; 54min ago
paul@ubuntu1804:/etc/mysql/mariadb.conf.d$ systemctl stop ufw
再確認一下服務狀態
paul@ubuntu1804:/etc/mysql/mariadb.conf.d$ systemctl status ufw
?? Active: inactive (dead)
九、再次在MySQL Workbench里點擊Test Connection,
連接測試成功。
十、以后可以雙擊這個連接進入圖形界面管理MariaDB,里面能直觀的看到系統狀態。
=================================================================
附:APT的代理設置文件還可以這么寫:
Acquire {
? HTTP::proxy "http://10.0.0.10:3128";
? HTTPS::proxy "http://10.0.0.10:3128";
}
https://www.serverlab.ca/tutorials/linux/administration-linux/how-to-set-the-proxy-for-apt-for-ubuntu-18-04/
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。