溫馨提示×

CentOS7上怎么安裝和配置MariaDB數(shù)據(jù)庫

小億
96
2024-03-04 16:15:24
欄目: 云計算

要在CentOS7上安裝和配置MariaDB數(shù)據(jù)庫,請按照以下步驟操作:

  1. 更新系統(tǒng)軟件包:
sudo yum update
  1. 安裝MariaDB數(shù)據(jù)庫:
sudo yum install mariadb-server
  1. 啟動MariaDB服務(wù)并設(shè)置為開機自啟動:
sudo systemctl start mariadb
sudo systemctl enable mariadb
  1. 運行安全性腳本以提高數(shù)據(jù)庫安全性并按照提示設(shè)置密碼:
sudo mysql_secure_installation
  1. 登錄MariaDB數(shù)據(jù)庫:
sudo mysql -u root -p
  1. 在MariaDB數(shù)據(jù)庫中創(chuàng)建新用戶和數(shù)據(jù)庫:
CREATE DATABASE dbname;
CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON dbname.* TO 'username'@'localhost';
FLUSH PRIVILEGES;
  1. 退出MariaDB數(shù)據(jù)庫并重新登錄以驗證新用戶和數(shù)據(jù)庫是否已成功創(chuàng)建:
exit
sudo mysql -u username -p
USE dbname;

現(xiàn)在,您已經(jīng)成功在CentOS7上安裝和配置MariaDB數(shù)據(jù)庫。您可以開始在該數(shù)據(jù)庫中創(chuàng)建表格和插入數(shù)據(jù)。

0