1. 程式人生 > >mysql 安裝以及卸載 CentOS 7

mysql 安裝以及卸載 CentOS 7

lib64 install style get ogr mariadb data fin rpm

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 root@localhost identified by ‘Ad2cdf213@fb‘;

修改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包
[root@iZbp1ddkszxcmrqic0imjwZ ~]# 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所有目錄文件
[root@iZbp1ddkszxcmrqic0imjwZ ~]# 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