先下载包,MySQL8.0以上压缩机制变了后缀为XZ
1上传mysql-5.7.21-linux-glibc2.12-x86_64.tar
2. tar -xvf mysql-8.0.19-linux-glibc2.12-x86_64.tar
将文件移到
mv 文件名/* /usr/local/mysql ;
3.mkdir -p /usr/local/mysql/data
4.创建组 mysql;
groupadd mysql
5.创建mysql组下mysql用户
useradd -r -g mysql mysql
6.密码
passwd mysql
7.给权限
chown -R mysql:mysql /usr/local/mysql/data/; chmod -R 755 /usr/local/mysql/data/;
8.初始化
/usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
第一个坑来了;
执行时候包错
error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
意思就是无法打开;
解决方案:
yum install libaio
再次运行:
/usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
就会出现:
2021-01-11T10:52:57.423278Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symb olic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release.
2021-01-11T10:52:57.423441Z 0 [System] [MY-013169] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.19) initializing of server in progress as process 4109
2021-01-11T10:53:02.437156Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@loc alhost: HafEyDlSL8_p
root@localhost:后面就是root初始密码;
9.启动服务:
sh /usr/local/mysql/support-files/mysql.server start
启动成功;没有配置my.cnf和init.d/mysql;
10.配置init.d/mysql
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
11.修改my.cnf
basedir=/usr/local/mysql/
datadir=/usr/local/mysql/data
socket=/tmp/mysql.sock
character-set-server=UTF8MB4
12.重启
service mysql restart
ok;还有一个坑
启动成功了,却没有mysql 指令;
解决方法
vim /etc/profile
在最尾部添加
export PATH=$PATH://usr/local/mysql/bin
重新加载profile
source /etc/profile
13.验证一下;
mysql -u root -p
OK;打完收工;希望对你们有用;