centos7使用yum install mariadb-server命令安装的默认版本是5.5的,这是因为系统默认源只有5.5的版本,所以我们去增加一个10.6的源
去mariaDB官网找到对应的源
Download MariaDB Server - MariaDB.org
这是我选的源
复制这部分作为centos7的源
# MariaDB 10.6 CentOS repository list - created 2021-12-22 11:16 UTC # https://mariadb.org/download/ [mariadb] name = MariaDB baseurl = https://mirrors.aliyun.com/mariadb/yum/10.6/centos7-amd64 gpgkey=https://mirrors.aliyun.com/mariadb/yum/RPM-GPG-KEY-MariaDB gpgcheck=1
vim /etc/yum.repos.d/MariaDB.repo
把刚在mariadb官网复制的源代码粘贴进去
源的问题解决了,现在可以执行安装了,再次执行该命令就会发现安装的是10.6的版本了
yum install MariaDB-server MariaDB-client
mariadb-secure-installation
Enter current password for root (enter for none): 输入当前的root密码(默认空),直接回车
Set root password? [Y/n] 设置新密码,y
Remove anonymous users? [Y/n] 移除匿名用户,y
Disallow root login remotely? [Y/n] 禁止root用户远程登录,y
Remove test database and access to it? [Y/n] 移除测试数据库,y
Reload privilege tables now? [Y/n] y
启动
systemctl start mariadb
设置开机自启
systemctl enable mariadb
配置文件位置:/etc/my.cnf