yum安装
https://www.cnblogs.com/xieshangxi/p/12470251.html
1、卸载mariadb
yum list installed | grep mariadb #检查mariadb是否已安装
yum -y remove mariadb* #全部卸载
2、下载并安装mysql的YUM源
2、停止mysql服务、删除之前安装的mysql
删除命令:rpm -e –nodeps 包名
rpm安装-------------------------------
1、查找以前是否装有mysql
命令:rpm -qa|grep -i mysql
rpm -ev MySQL-client-5.5.25a-1.rhel5
#rpm -ev MySQL-server-5.5.25a-1.rhel5
3、查找之前老版本mysql的目录、并且删除老版本mysql的文件和库
find / -name mysql
查找结果如下:
[root@localhost ~]# find / -name mysql
/var/lib/mysql
/var/lib/mysql/mysql
/usr/lib64/mysql
删除对应的mysql目录
rm -rf /var/lib/mysql
rm -rf /var/lib/mysql
rm -rf /usr/lib64/mysql
具体的步骤如图:查找目录并删除
注意:卸载后/etc/my.cnf不会删除,需要进行手工删除
rm -rf /etc/my.cnf
4、再次查找机器是否安装mysql
rpm -qa|grep -i mysql
无结果,说明已经卸载彻底、接下来直接安装mysql即可
如果是使用yum安装的mysql,使用如下命令进行卸载(不能确定使用何种方式安装的mysql情况下,按后续步骤一一进行处理即可):
#yum remove mysql mysql-server mysql-libs compat-mysql51
rm -rf /var/lib/mysq
rm /etc/my.cnf
然后删除mysql相关的服务。
chkconfig --list | grep -i mysql
chkconfig --del mysql
然后找出OS中分散的mysql文件夹,并删除。
find / -name mysql
最后清空mysql相关的的所有目录以及文件
rm -rf 加目录
使用yum提示Error: rpmdb open failed的解决方案
[root@www~]# cd /var/lib/rpm # rpmdb所在目录
[root@www rpm]# rm -f __db.* # 清除原rpmdb文件
[root@www rpm]# rpm --rebuilddb # 重建rpm数据库
[root@www rpm]# yum clean all # 清除所有yum的缓存
报错处理:
Job for mariadb.service failed because the control process exited with error code. See “systemctl status mariadb.service” and “journalctl -xe” for details.
先开一个屏幕监控错误,然后vim /etc/my.cnf,查data路径指向
CD、
my.cnf 的配置
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
skip-name-resolve
Settings user and g-roup are ignored when systemd is used.
If you need to run mysqld under a different user or group,
customize your systemd unit file for mariadb according to the
instructions in http://fedoraproject.org/wiki/Systemd
[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid
#validate_password=off
#default-storage-engine=INNODB
#character-set-server=utf8
#collation-server=utf8_general_ci
include all files from the config directory
!includedir /etc/my.cnf.d