1、说明
安装 mariadb 数据,这个数据库是 mysql 的一个分支,有专人维护,推荐使用。毕竟 mysql 已经被 oracle 收购了,你懂得。
2、安装 mariadb
# 安装mariadb(mysql)数据库
[root@centos ~]# yum install mariadb mariadb-server -y
[root@centos ~]# systemctl start mariadb # 启动mariadb服务
[root@centos ~]# systemctl enable mariadb # 使mariadb服务开机自启
[root@centos ~]# mysql_secure_installation # 配置mariadb数据库
# 1.会提示你输入当前的root密码
Enter current password for root (enter for none): # 如果没有设置过,就直接回车
Set root password? [Y/n] # 2.提示是否设置root密码,输入y,回车
New password: # 3.输入root密码
Re-enter new password: # 4.确认root密码
Remove anonymous users? [Y/n] # 5.移除匿名用户,输入y,回车
# 6.禁用远程root用户登录,这个看个人需求,如果你想在远程连接mysql,你就输入n,回车;
# 如果为了安全考虑,不允许的话,输入y,回车
Disallow root login remotely? [Y/n] # 7.是否移除test数据库,不想要的话,输入y,回车
Remove test database and access to it? [Y/n]
Reload privilege tables now? [Y/n] # 8.刷新权限、表,输入y,回车
# 至此,mariadb安装、配置完成。
# 注: 配置 mariadb 中出现的 root 是数据库的用户名 root,非 centos 的 root.
# 进入mysql
[root@centos ~]# mysql -u root -p
Enter password:
3、卸载 mariadb
[root@centos ~]# yum remove mariadb # 卸载 mariadb
[root@centos ~]# yum list installed|grep mariadb # 查看卸载后的安装情况
[root@centos ~]# rm -f /etc/my.cnf # 删除配置文件
[root@centos ~]# rm -rf /var/lib/mysql/ # 删除数据目录
完毕!