本文將介紹在openeuler操作系統中安裝資料庫的方案,並提供代碼示例。
一、安裝MariaDB
下面介紹如何在openeuler中安裝MariaDB。
1、更新軟體源
sudo dnf update
2、安裝MariaDB
sudo dnf install mariadb mariadb-server
安裝過程中,系統會提示輸入root用戶密碼。安裝完成後,啟動MariaDB並設置開機自啟。
sudo systemctl start mariadb
sudo systemctl enable mariadb
二、安裝MySQL
下面介紹如何在openeuler中安裝MySQL。
1、更新軟體源
sudo dnf update
2、安裝MySQL
sudo dnf install mysql mysql-server
安裝過程中,系統會提示輸入root用戶密碼。安裝完成後,啟動MySQL並設置開機自啟。
sudo systemctl start mysqld
sudo systemctl enable mysqld
三、安裝PostgreSQL
下面介紹如何在openeuler中安裝PostgreSQL。
1、更新軟體源
sudo dnf update
2、安裝PostgreSQL
sudo dnf install postgresql postgresql-server
安裝完成後,初始化資料庫並啟動。
sudo postgresql-setup initdb
sudo systemctl start postgresql
sudo systemctl enable postgresql
四、安裝MongoDB
下面介紹如何在openeuler中安裝MongoDB。
1、創建MongoDB的軟體源
sudo tee /etc/yum.repos.d/mongodb-org-4.4.repo << EOF
[mongodb-org-4.4]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/8/mongodb-org/4.4/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.4.asc
EOF
2、安裝MongoDB
sudo dnf install mongodb-org
安裝完成後,啟動MongoDB並設置開機自啟。
sudo systemctl start mongod
sudo systemctl enable mongod
五、總結
本文介紹了在openeuler操作系統中安裝MariaDB、MySQL、PostgreSQL和MongoDB的方案,並提供了相應的代碼示例。根據自己的需求選擇合適的資料庫進行安裝即可。
原創文章,作者:PVJXI,如若轉載,請註明出處:https://www.506064.com/zh-tw/n/375502.html