mysql 安装以及卸载 CentOS 7
Posted shijunjie
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysql 安装以及卸载 CentOS 7相关的知识,希望对你有一定的参考价值。
wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.24-1.el7.x86_64.rpm-bundle.tar
安装:
mkdir mysql
tar -xf mysql-5.7.22-1.el7.x86_64.rpm-bundle.tar -C mysql
cd mysql
rpm -qa | grep mariadb
rpm -e mariadb-libs-5.5.56-2.el7.x86_64 --nodeps
yum -y install openssl openssl-devel libaio libaio-devel
rpm -ivh mysql-community-common-5.7.22-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.22-1.el7.x86_64.rpm
rpm -ivh mysql-community-devel-5.7.22-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.22-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.22-1.el7.x86_64.rpm
启动:
service mysqld start
grep ‘temporary password‘ /var/log/mysqld.log
修改root密码
mysql> alter user [email protected] identified by ‘[email protected]‘;
修改root登陆权限:
mysql> use mysql;
mysql> update user set host = ‘%‘ where user = ‘root‘;
mysql> select host, user from user;
mysql> flush privileges;
配置存储位置
1、修改配置文件
vim /etc/my.cnf
#datadir=/var/lib/mysql datadir=/home/mysql/mysqldatadir01 socket=/var/lib/mysql/mysql.sock #log-error=/var/log/mysqld.log log-error=/home/mysql/mysqllog_error_01/mysqld.log pid-file=/var/run/mysqld/mysqld.pid
2、然后把原先位置的数据全部拷贝到新的目录
cp -rf 。。。。。。
3、最后重启mysql验证
卸载
卸载mysql的方法:
首先停用mysql: service mysqld stop
第一步:卸载所有mysql包
[[email protected] ~]# rpm -qa | grep mysql
mysql-community-common-5.7.21-1.el6.x86_64
mysql-community-devel-5.7.21-1.el6.x86_64
mysql-community-server-5.7.21-1.el6.x86_64
mysql-community-libs-5.7.21-1.el6.x86_64
mysql-community-client-5.7.21-1.el6.x86_64
卸载命令: rpm -e --nodeps mysql包
第二步:卸载mysql所有目录文件
[[email protected] ~]# find / -name mysql
/usr/share/mysql
/usr/include/mysql
/usr/include/mysql/mysql
/usr/bin/mysql
/usr/lib64/mysql
/root/mysql
/var/lib/mysql
/var/lib/mysql/mysql
/etc/logrotate.d/mysql
卸载命令: rm -rf mysql路径
第三步:卸载my.cnf. 和 /var/log/mysqld.log 文件
rm -rf /etc/my.cnf
以上是关于mysql 安装以及卸载 CentOS 7的主要内容,如果未能解决你的问题,请参考以下文章
CentOS 7.x 卸载删除MariaDB,重新安装,安装MYSQL离线版和源代码