MySQL5.7.26二进制安装

时间:2021-12-14 05:59:46

1、安装系统版本

MySQL5.7.26二进制安装

2、解压更换路径

tar xf mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz
mv mysql-5.7.26-linux-glibc2.12-x86_64 /application/mysql-5.7.26
/application/mysql-5.7.26

3、创建用户,并给数据文件授予权限

groupadd mysql
useradd -r -g mysql mysql

4、创建MySQL数据目录

mkdir -p  /application/mysql-5.7.26/data

5、授权

chown mysql:mysql -R /application/mysql-5.7.26/

6、配置参数

vim /etc/my.cnf

[mysqld]
user = mysql
port = 3306
basedir = /application/mysql-5.7.26
datadir = /application/mysql-5.7.26/data
log-bin = /application/mysql-5.7.26/data/mysql-bin
skip-name-resolve
server-id=6
lower_case_table_names=1
max_connections=1200
[mysqld_safe]
log-error= /application/mysql-5.7.26/data/mysqld.err
pid-file= /application/mysql-5.7.26/data/mysqld.pid

7、初始化mysql

yum install autoconf -y

cd /application/mysql-5.7.26/
./bin/mysqld --initialize --user=mysql --basedir=/application/mysql-5.7.26 --datadir=/application/mysql-5.7.26/data
 

8、找出MySQL默认密码、

cat /application/mysql-5.7.26/data/mysql.err

MySQL5.7.26二进制安装

9、添加启动命令及环境变量

[root@k8s-node111 mysql-5.7.26]# cp -a ./support-files/mysql.server /etc/init.d/mysqld
ln -s /application/mysql-5.7.26/bin/mysql /usr/bin
chown 777 /etc/my.cnf
chmod +x /etc/init.d/mysqld
/etc/init.d/mysqld restart echo 'PATH=/application/mysql-5.7.26/bin/:$PATH' >>/etc/profile
tail -1 /etc/profile
source /etc/profile
echo $PATH
mysql

10、登录root用户重置密码:

mysql -uroot -p初始密码
SET PASSWORD = PASSWORD('hongjun123');
ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;
flush privileges;

MySQL5.7.26二进制安装