安装MariaDB
1.切换到root用户,首先执行rpm -qa | grep -i mysql
检查一下是否有已安装的与MySQL相关的东西,如果有,使用rpm -e --nodeps mysql*
进行强制卸载
2.使用yum安装MariaDB,执行yum -y install mariadb mariadb-server
3.安装完成后,执行systemctl start mariadb
启动MariaDB,执行systemctl enable mariadb
设置开机启动
配置MariaDB
1.执行mysql_secure_installation
进行相关配置
- 首先是设置密码,会提示先输入密码:
* Enter current password for root (enter for none):<–初次运行直接回车
- 设置密码
* Set root password? [Y/n] <– 是否设置root用户密码,输入y并回车或直接回车
* New password: <– 设置root用户的密码
* Re-enter new password: <– 再输入一次你设置的密码
- 其它配置
* Remove anonymous users? [Y/n] <– 是否删除匿名用户,回车
* Disallow root login remotely? [Y/n] <–是否禁止root远程登录,回车,
* Remove test database and access to it? [Y/n] <– 是否删除test数据库,回车
* Reload privilege tables now? [Y/n] <– 是否重新加载权限表,回车
2.配置完成后,执行mysql -uroot -ppassword
测试登录。其中root为要登录的用户名,password为刚才设置的root用户的密码
3.测试成功后,配置MariaDB的字符集
- 使用vi编辑器打开/etc/my.cnf,在[mysqld]中添加
init_con