首先需要添加 yum 的源,通过一个官方脚本可以执行
curl -sS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | sudo bash
然后执行安装,会安装最新版本数据库
yum install MariaDB-server
安装完之后,查看运行状态
systemctl status mysql
启动数据库
systemctl start mysql
设置开机启动
systemctl enable mysql
进入mysql数据库控制台
mysql
创建数据库和对应的用户/密码
-- 创建数据库
create database homework default character set utf8mb4 collate utf8mb4_unicode_ci;
-- 创建用户
create user homework identified by 'xxxx';
-- 分配权限
grant all privileges on homework.* to 'homework'@'localhost' identified by 'xxxx' with grant option;
grant all privileges on homework.* to 'homework'@'%' identified by 'xxxx' with grant option;
flush privileges ;