1.卸载 先停掉mysql进程 没有安装过的可以直接跳过
pkill -9 mysqld
rpm -qa|grep -i mysql
yum -y remove mysql-community-client-5.6.38-2.el7.x86_64
依次卸载 直到没有
复制代码
2.下载mysql的repo源 这个安装的mysql5.7.20
[root@localhost ~]# cd /usr/local/src/ [root@localhost src]# wget repo.mysql.com/mysql57-com…
[root@localhost src]# rpm -ivh mysql57-community-release-el7-8.noarch.rpm
[root@localhost src]# yum -y install mysql-server
(也可以指定安装目录 yum --installroot=/usr/local/mysql --releasever=/ -y install mysql-server )我没试,这样装环境变量配置都不用你管,装上直接启动就行。安装路径是默认的。
配置 my.cnf vim /etc/my.cnf
[mysqld]
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
server_id = 1
expire_logs_days = 3
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
复制代码
- 启动mysql服务
service mysqld restart
输入 mysql -u root -p 密码 进入