1、mysql二进制下载安装
下载地址 https://dev.mysql.com/downloads/mysql/5.7.html#downloads
下载地址 https://dev.mysql.com/downloads/mysql/5.7.html#downloads
2、上传到/usr/local/src
3、解压
mkdir -p /usr/local/mysql
tar xf mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz
mv mysql-5.7.24-linux-glibc2.12-x86_64/* /usr/local/mysql
4、新增mysql用户,授权用户
useradd -s /sbin/nologin -M mysql
chown -R mysql.mysql /usr/local/mysql
5、安装依赖包
yum install libaio -y
6、安装msyql
cd /usr/local/mysql
./bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
提示:这里会生成随机密码,记下来(比如:#BOV*H%Zn8o=)
7、配置my.cnf
vim /etc/my.cnf
[mysqld] character-set-server=utf8 datadir=/usr/local/mysql/data basedir=/usr/local/mysql socket=/tmp/mysql.sock
8、设置开启启动
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
chkconfig --add mysqld
9、设置环境变量
vim /etc/profile
MYSQL_HOME=/usr/local/mysql export PATH=$PATH:$MYSQL_HOME/bin
#生效
source /etc/profile
10、启动修改密码
/etc/init.d/mysqld start mysql> set password = password('mysql');