groupadd mysql
useradd -r -g mysql -s /bin/false mysql
wget http://mirrors.163.com/mysql/Downloads/MySQL-5.7/mysql-5.7.31-linux-glibc2.12-x86_64.tar.gz
yum -y install libaio numactl-libs
tar xf mysql-5.7.31-linux-glibc2.12-x86_64.tar.gz -C /usr/local
cd /usr/local/
ln -s mysql-5.7.31-linux-glibc2.12-x86_64/ mysql
chown -R root.root /usr/local/mysql/
echo 'PATH=/usr/local/mysql/bin:$PATH' > /etc/profile.d/mysql.sh
. /etc/profile.d/mysql.sh
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
mysqld --initialize --user=mysql --datadir=/data/mysql
grep password /data/mysql/mysql.log
或 awk '/temporary password/{print $NF}' /data/mysql/mysql.log
mysqld --initialize-insecure --user=mysql --datadir=/data/mysql
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
chkconfig --add mysqld
service mysqld start
#修改前面生成的随机密码为指定密码
mysqladmin -uroot -p'LufavlMka6,!' password 123456
#修改前面生成的空密码为指定密码
mysqladmin -uroot password 123456
/etc/my.cnf是需要清空的,步骤里有备份一个然后重新写
5.7版本初始化有一个随机密码需要手动获取后重置,本文中的随机密码不能直接拿来直接用!