1.下载MySQL 5.7.26安装包
2.上传MySQL 5.7.26安装包,并解压,创建软连接
gunzip mysql‐5.7.26‐linux‐glibc2.12‐x86_64.tar.gz
tar -xvf mysql-5.7.26-linux-glibc2.12-x86_64.tar
ln -s /stage/mysql-5.7.26-linux-glibc2.12-x86_64 /usr/local/mysql
3.添加用户组,用户,创建目录,修改相关目录权限
groupadd mysql
useradd -g mysql mysql
chown -R mysql.mysql /usr/local/mysql*
mkdir -p /data/3306/datadir
mkdir -p /data/3306/binlog
chown -R mysql.mysql /data*
4.修改profile
vi /etc/profile
export PATH=/usr/local/mysql/bin:$PATH
source /etc/profile
5.初始化
mysqld ‐‐initialize‐insecure ‐‐user=mysql ‐‐basedir=/usr/local/mysql ‐‐datadir=/data/3306/data
6.修改配置文件
vi /etc/my.cnf
[mysqld]
user=mysql
basedir=/usr/local/mysql
datadir=/data/3306/data
log_bin=/data/3306/binlog/mysql‐bin
port=3306
server_id=7
socket=/tmp/mysql.sock
[mysql]
socket=/tmp/mysql.sock
7.准备启动脚本
cd /usr/local/mysql/support‐files/
cp /usr/local/mysql/support‐files/mysql.server /etc/init.d/mysqld
vi /etc/init.d/mysqld
basedir=/usr/local/mysql
datadir=/data/3306/data
/etc/init.d/mysqld start
8.修改密码
方法一:mysqladmin -uroot -p password
方法二:alter user root@localhost identified by ‘mysql‘;