centos7安装mariadb

本文档详细介绍了在CentOS7系统上安装Mariadb数据库的过程,包括使用yum安装,启动并设置开机启动,以及通过mysql_secure_installation进行安全配置,如设置root密码、移除匿名用户等。最后展示了如何连接数据库并查看已有的数据库。
摘要由CSDN通过智能技术生成

centos7安装mariadb

mariadb是MYSQL的一个分支,语法基本和mysql一样,而且兼容mysql,centos7中自带了mariadb的软件包。

[root@cn7]/# cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)
[root@cn7]/# uname -a
Linux cn7 3.10.0-1160.el7.x86_64 #1 SMP Mon Oct 19 16:18:59 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

安装mariadb:

[root@cn7]/# yum -y install mariadb-server

开启mariadb并设置开机启动:

[root@cn7]/# systemctl start mariadb
[root@cn7]/# systemctl enable mariadb
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.

配置数据库

[root@cn7]/# mysql_secure_installation
Enter current password for root (enter for none):  # 输入数据库超级管理员root的密码(注意不是系统root的密码),第一次进入还没有设置密码则直接回车

Set root password? [Y/n]  # 设置密码,y

New password:  # 新密码
Re-enter new password:  # 再次输入密码

Remove anonymous users? [Y/n]  # 移除匿名用户, y

Disallow root login remotely? [Y/n]  # 拒绝root远程登录,n,不管y/n,都会拒绝root远程登录

Remove test database and access to it? [Y/n]  # 删除test数据库,y:删除。n:不删除,数据库中会有一个test数据库,一般不需要

Reload privilege tables now? [Y/n]  # 重新加载权限表,y

启动数据库

[root@cn7]/# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.68-MariaDB MariaDB Server

Copyright (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)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)

MariaDB [(none)]> quit;
Bye
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值