查看系统版本
[root@mysql ~]# cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)
mariadb
查看系统是否存在mariadb
[root@mysql ~]# rpm -qa |grep mariadb
[root@mysql ~]# yum install mariadb-server mariadb # 安装
systemctl enable --now mariadb # 启动数据库,并配置开机自动启动
mysql_secure_installation # 使用以下命令初始化mariadb并配置root密码为123456
# 执行命令:mysql_secure_installation
# 直接回车,空
# 是否设置密码:y
# 输入设置密码:123456
# 再次输入密码:123456
# 是否移除anonymous用户:y
# 是否不允许root远程登录:n
# 是否移除test数据库:y
mysql
1.官网下载安装mysql-server
[root@mysql ~]# wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
[root@mysql ~]# rpm -ivh mysql-community-release-el7-5.noarch.rpm
[root@mysql ~]# yum install mysql-community-server
2.安装成功后重启mysql服务。
[root@mysql ~]# service mysqld restart 或 systemctl enable --now mysqld
3.初次安装mysql,root账户没有密码。直接回车
[root@mysql ~]# mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.51 MySQL Community Server (GPL)
Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rig