touch /etc/yum.repos.d/mariadb.repo #创建文件
vim /etc/yum.repos.d/mariadb.repo #编辑文件
文件内容
[mariadb]
name = MariaDB
baseurl = https://mirrors.tuna.tsinghua.edu.cn/mariadb/yum/10.5/centos7-amd64
gpgkey=https://mirrors.tuna.tsinghua.edu.cn/mariadb/yum/RPM-GPG-KEY-MariaDB
gpgcheck=1
yum clean all
yum install MariaDB-server MariaDB-client -y
systemctl start mariadb
sudo systemctl enable mariadb
新建数据库用户
sudo mysql -u root
CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password123';
CREATE USER 'newuser'@'%' IDENTIFIED BY 'password123';
GRANT ALL PRIVILEGES ON mydb.* TO 'newuser'@'localhost';
GRANT ALL PRIVILEGES ON mydb.* TO 'newuser'@'%';
FLUSH PRIVILEGES;