千家信息网

CentOS系统中如何安装和使用MariaDB数据库?

发表于:2025-11-07 作者:千家信息网编辑
千家信息网最后更新 2025年11月07日,1、查询MariaDB包[root@test ~]# yum list all | grep mariadb2、安装mariaDB[root@test ~]# yum -y install maria
千家信息网最后更新 2025年11月07日CentOS系统中如何安装和使用MariaDB数据库?

1、查询MariaDB包

[root@test ~]# yum list all | grep mariadb

2、安装mariaDB

[root@test ~]# yum -y install mariadb-server

3、配置mariaDB

[root@test ~]# systemctl start mariadb         #启动MariaDB[root@test ~]# systemctl enable mariadb        #设置MariaDB为开机自启动[root@test ~]# netstat -ntlp              #查看3306端口是否成功启动[root@test ~]# mysql_secure_installation        #首次安装需要进行数据库的配置Enter current password for root (enter for none):  # 输入数据库超级管理员root的密码(注意不是系统root的密码),第一次进入还没有设置密码则直接回车Set root password? [Y/n]  # 设置密码,yNew password:  # 新密码Re-enter new password:  # 再次输入密码Remove anonymous users? [Y/n]  # 移除匿名用户, yDisallow root login remotely? [Y/n]  # 拒绝root远程登录,yRemove test database and access to it? [Y/n]  # 删除test数据库,y:删除。n:不删除,数据库中会有一个test数据库,一般不需要Reload privilege tables now? [Y/n]  # 重新加载权限表,y。或者重启服务也许

4、登录测试mariaDB

[root@test ~]# mysql -u root -pEnter password:Welcome to the MariaDB monitor.  Commands end with ; or \g.Your MariaDB connection id is 8Server version: 5.5.60-MariaDB MariaDB ServerCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.MariaDB [(none)]>MariaDB [(none)]>quit


0