自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

在 Linux 上安裝 MariaDB 或 MySQL

系統(tǒng) Linux MariaDB
MariaDB 和 MySQL 都是使用 SQL 的開源數(shù)據(jù)庫(kù),并且共享相同的初始代碼庫(kù)。MariaDB 是 MySQL 的替代品,你可以使用相同的命令(mysql)與 MySQL 和 MariaDB 數(shù)據(jù)庫(kù)進(jìn)行交互。因此,本文同時(shí)適用于 MariaDB 和 MySQL。

[[347856]]

開始在 Linux 系統(tǒng)上使用開源的 SQL 數(shù)據(jù)庫(kù)吧。

MariaDB 和 MySQL 都是使用 SQL 的開源數(shù)據(jù)庫(kù),并且共享相同的初始代碼庫(kù)。MariaDB 是 MySQL 的替代品,你可以使用相同的命令(mysql)與 MySQL 和 MariaDB 數(shù)據(jù)庫(kù)進(jìn)行交互。因此,本文同時(shí)適用于 MariaDB 和 MySQL。

安裝 MariaDB

你可以使用你的 Linux 發(fā)行版的包管理器安裝 MariaDB。在大多數(shù)發(fā)行版上,MariaDB 分為服務(wù)器包和客戶端包。服務(wù)器包提供了數(shù)據(jù)庫(kù)“引擎”,即 MariaDB 在后臺(tái)運(yùn)行(通常在物理服務(wù)器上)的部分,它監(jiān)聽數(shù)據(jù)輸入或數(shù)據(jù)輸出請(qǐng)求??蛻舳税峁┝?nbsp;mysql 命令,你可以用它來與服務(wù)器通信。

在 RHEL、Fedora、CentOS 或類似的發(fā)行版上:

  1. $ sudo dnf install mariadb mariadb-server

在 Debian、Ubuntu、Elementary 或類似的發(fā)行版上:

  1. $ sudo apt install mariadb-client mariadb-server

其他操作系統(tǒng)可能會(huì)以不同的打包系統(tǒng)封裝 MariaDB,所以你可能需要搜索你的軟件倉(cāng)庫(kù)來了解你的發(fā)行版的維護(hù)者是如何提供它的。

啟動(dòng) MariaDB

因?yàn)?MariaDB 被設(shè)計(jì)為部分作為數(shù)據(jù)庫(kù)服務(wù)器,它可以在一臺(tái)計(jì)算機(jī)上運(yùn)行,并從另一臺(tái)計(jì)算機(jī)上進(jìn)行管理。只要你能訪問運(yùn)行它的計(jì)算機(jī),你就可以使用 mysql 命令來管理數(shù)據(jù)庫(kù)。在寫這篇文章時(shí),我在本地計(jì)算機(jī)上運(yùn)行了 MariaDB,但你同樣可與遠(yuǎn)程系統(tǒng)上托管的 MariaDB 數(shù)據(jù)庫(kù)進(jìn)行交互。

在啟動(dòng) MariaDB 之前,你必須創(chuàng)建一個(gè)初始數(shù)據(jù)庫(kù)。在初始化其文件結(jié)構(gòu)時(shí),你應(yīng)該定義你希望 MariaDB 使用的用戶。默認(rèn)情況下,MariaDB 使用當(dāng)前用戶,但你可能希望它使用一個(gè)專用的用戶帳戶。你的包管理器可能為你配置了一個(gè)系統(tǒng)用戶和組。使用 grep 查找是否有一個(gè) mysql 組:

  1. $ grep mysql /etc/group
  2. mysql:x:27:

你也可以在 /etc/passwd 中尋找這個(gè)專門的用戶,但通常情況下,有組就會(huì)有用戶。如果沒有專門的 mysql 用戶和組,可以在 /etc/group 中尋找一個(gè)明顯的替代品(比如 mariadb)。如果沒有,請(qǐng)閱讀你的發(fā)行版文檔來了解 MariaDB 是如何運(yùn)行的。

假設(shè)你的安裝使用 mysql,初始化數(shù)據(jù)庫(kù)環(huán)境:

  1. $ sudo mysql_install_db --user=mysql
  2. Installing MariaDB/MySQL system tables in '/var/lib/mysql'...
  3. OK
  4. [...]

這一步的結(jié)果顯示了接下來你必須執(zhí)行的配置 MariaDB 的任務(wù):

  1. PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !
  2. To do so, start the server, then issue the following commands:
  3.  
  4. '/usr/bin/mysqladmin' -u root password 'new-password'
  5. '/usr/bin/mysqladmin' -u root -h $(hostname) password 'new-password'
  6.  
  7. Alternatively you can run:
  8. '/usr/bin/mysql_secure_installation'
  9.  
  10. which will also give you the option of removing the test
  11. databases and anonymous user created by default.  This is
  12. strongly recommended for production servers.

使用你的發(fā)行版的初始化系統(tǒng)啟動(dòng) MariaDB:

  1. $ sudo systemctl start mariadb

在啟動(dòng)時(shí)啟用 MariaDB 服務(wù)器:

  1. $ sudo systemctl enable --now mariadb

現(xiàn)在你已經(jīng)有了一個(gè) MariaDB 服務(wù)器,為它設(shè)置一個(gè)密碼:

  1. mysqladmin -u root password 'myreallysecurepassphrase'
  2. mysqladmin -u root -h $(hostname) password 'myreallysecurepassphrase'

最后,如果你打算在生產(chǎn)服務(wù)器上使用它,請(qǐng)?jiān)谏暇€前運(yùn)行 mysql_secure_installation 命令。 

責(zé)任編輯:龐桂玉 來源: Linux中國(guó)
相關(guān)推薦

2010-05-20 15:15:59

MySQL Serve

2019-04-28 10:00:11

UbuntuLinuxMySQL

2022-06-16 10:46:43

UbuntuLinux

2019-10-22 09:50:46

Intel NUC安裝Linux

2021-08-22 08:43:23

LVMLinux MintLinux

2023-10-17 11:27:42

2019-10-16 17:00:51

LinuxUbuntuVMware

2021-10-02 10:15:19

UbuntuLinuxAnyDesk

2023-11-09 16:13:53

2023-10-11 09:02:27

2018-02-26 08:14:20

LinuxDocker容器

2009-06-29 08:35:59

Linux

2022-12-03 16:02:51

2021-12-03 15:04:06

FlatpakLinux

2018-09-08 10:16:18

數(shù)據(jù)庫(kù)MySQLMariaDB

2019-12-02 09:46:18

Fedora 30 SLEMPLinux

2009-03-10 10:53:42

安裝ApacheMySQL

2022-10-08 08:41:32

JDBCJavaLinux

2023-10-15 14:53:22

Arch LinuxYay

2019-08-01 09:52:46

LinuxNetData性能監(jiān)控工具
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)