centos mysql5.7 二进制包安装

时间:2020-12-15 20:58:58

此种方式安装非常简单

cd /usr/local

下载安装包
wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz

解压
tar -zxvf mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz


[root@www local]# pwd
/usr/local
[root@www local]# mv mysql-5.7.17-linux-glibc2.5-x86_64 mysql


cd mysql

mkdir -p /data/mysql/data

创建mysql 用户

useradd mysql -s /sbin/nologin -M(没有家目录)

chown -R mysql.mysql /data/mysql

./bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql/data

提示初始密码:
2017-03-29T15:09:12.116410Z 1 [Note] A temporary password is generated for root@localhost: ew/Wx(<Z>43l

拷贝启动脚本文件

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

设置开机启动

chkconfig mysqld on

chkconfig --list|grep mysqld
chmod 755 /etc/init.d/mysqld

配置环境变量
echo 'PATH=/usr/local/mysql/bin/:$PATH' >> /etc/profile

. /etc/profile

编辑my.cnf

[mysqld]
datadir=/data/mysql/data
socket=/tmp/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd

[mysqld_safe]
log-error=/data/mysql/log/mariadb/mariadb.log
pid-file=/data/mysql/run/mariadb/mariadb.pid

#
# include all files from the config directory
#
!includedir /etc/my.cnf.d

  

 

 

创建/data/mysql/log/xxx.log

启动mysql 

 

进入MySQL :

mysql -uroot -p ew/Wx(<Z>43l

修改密码
alter user 'root'@'localhost' identified by '123456';

flush privileges;

grant all privileges on *.* to 'root'@'%' identified by '123456';

FLUSH PRIVILEGES;