I will persist until I succeed
二进制安装MySQL 5.7
二进制安装MySQL 5.7

二进制安装MySQL 5.7

1、安装相关包

yum -y install libaio numactl-libs

2、创建用户和组

groupadd mysql

useradd -r -g mysql -s /bin/false mysql

3、准备二进制压缩包

tar xf mysql-5.7.38-linux-glibc2.12-x86_64.tar.gz) –C /usr/local

cd /usr/local/

ln -s mysql-5.7.38-linux-glibc2.12-x86_64 mysql

chown -R mysql.mysql /usr/local/mysql/

4、准备PATH变量

echo ‘PATH=/usr/local/mysql/bin:$PATH’ > /etc/profile.d/mysql.sh

. /etc/profile.d/mysql.sh

5、准备配置文件

cp /etc/my.cnf{,.bak}

vim /etc/my.cnf

[mysqld]

datadir=/data/mysql

skip_name_resolve=1

socket=/data/mysql/mysql.sock        

log-error=/data/mysql/mysql.log

pid-file=/data/mysql/mysql.pid

[client]

socket=/data/mysql/mysql.sock

6、生成数据库文件,并提取root密码

mysqld –initialize –user=mysql –datadir=/data/mysql

…省略…

2022-06-30T13:03:54.258140Z 1 [Note] A temporary password is generated for

root@localhost: LufavlMka6,!  #注意生成root的初始密码

grep password /data/mysql/mysql.log

2022-06-30T13:31:30.458826Z 1 [Note] A temporary password is generated for

root@localhost: LufavlMka6,!

awk ‘/temporary password/{print $NF}’ /data/mysql/mysql.log

LufavlMka6,!

7、准备服务脚本和启动

cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld

chkconfig –add mysqld

service mysqld start

8、修改密码

mysqladmin -uroot -p’LufavlMka6,!’   password 123456

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注