Centos7离线安装mysql8 glibc版本
1.查看mysql是否安装
yum list installed mysql*
或者:
rpm -qa | grep -i mysql
2.卸载
yum remove mysql*
3.删除残留文件
find / -name mysql
rm -rf /var/lib/mysql
rm -rf /etc/my.cnf
rm -rf /etc/profile.d/mysql.sh
rm -rf /etc/init.d/mysql
4.杀掉进程
ps -ef|grep mysql
5.建用户
useradd mysql
6.切用户
su - mysql
7.参考官方安装文档:https://dev.mysql.com/doc/refman/8.0/en/binary-installation.html
8.安装依赖包-root
yum install libaio
9.删除原有mariadb的配置文件-root
rm -rf /etc/my.cnf
10.下载glibc版本、解压、改文件名-mysql、建一些依赖目录
>wget https://mirrors.aliyun.com/mysql/MySQL-8.0/mysql-8.0.28-linux-glibc2.12-x86_64.tar.xz >cd mysql-8.0.28 >mkdir mysql-files >chown mysql:mysql mysql-files >chmod 750 mysql-files >mkdir data >chmod 755 data |
11.初始化
>$HOME/mysql-8.0.28/bin/mysqld --initialize --user=mysql --basedir=$HOME/mysql-8.0.28 --datadir=$HOME/mysql-8.0.28/data 报错: [MY-012582] [InnoDB] io_setup() failed with EAGAIN. Will make 5 attempts before giving up. 解决:root vi /etc/sysctl.conf fs.aio-max-nr=1045876 |
12.建服务
>bin/mysql_ssl_rsa_setup --datadir=$HOME/mysql-8.0.28/data >cp support-files/mysql.server /etc/init.d/mysql >vi /etc/rc.d/init.d/mysql 修改2行: |
13.启动、停止
[mysql@localhost mysql-8.0.28]$ service mysql start Starting MySQL.. SUCCESS! [mysql@localhost mysql-8.0.28]$ service mysql status SUCCESS! MySQL running (121408) [mysql@localhost mysql-8.0.28]$ service mysql stop Shutting down MySQL.. SUCCESS! [mysql@localhost mysql-8.0.28]$ |
12.改密码
/home/mysql/mysql-8.0.28/bin/mysql -uroot -p
alter user 'root'@'localhost' identified with mysql_native_password by '123456';
flush privileges;
13.开启远程连接
use mysql;
update user set host='your ip' where user='root'; //指定ip
update user set host='%' where user='root';//任意ip都可以连
flush privileges;