1.下载 这个包只有49M 但是在编译的时候时间长
wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-boost-5.7.24.tar.gz
安装依赖包
yum install -y cmake make gcc gcc-c++ bison ncurses ncurses-devel
创建用户
添加用户和组
[root@localhost ~]# groupadd mysql
[root@localhost ~]# useradd -M -s /sbin/nologin -r -g mysql mysql
[root@localhost opt]# mkdir -p /usr/local/mysql/data
mkdir -p /home/data/mysql57/data
mkdir -p /home/data/mysql57/log
[root@localhost ~]# chown -R mysql:mysql ./
编译安装 进入目录
[root@localhost mysql-5.7.24]#
cmake -DCMAKE_INSTALL_PREFIX=/home/data/mysql57 \
-DMYSQL_DATADIR=/home/data/mysql57/data \
-DSYSCONFDIR=/etc \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DMYSQL_UNIX_ADDR=/home/data/mysql57/mysql.sock \
-DMYSQL_TCP_PORT=3307 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DDOWNLOAD_BOOST=1 \
-DWITH_BOOST=/usr/local/src/mysql-5.7.24/boost/boost_1_59_0
make
make install
编辑配置文件
[root@xuegod63 ~]#vim /etc/my.cnf
[mysqld]
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
port=3306
socket=/usr/local/mysql/mysql.sock
character-set-server=utf8
log-error=/usr/local/mysql/log/mysqld.log
pid-file=/tmp/mysqld.pid
环境变量
vim /etc/profile
export PATH=/home/data/mysql57/bin:$PATH
拷贝启动脚本 授权
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
chown -R mysql:mysql /usr/local/mysql
初始化数据库
[root@localhost ~]#
/usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
grep password /usr/local/mysql/log/mysqld.log
修改密码
alter user 'root'@'localhost' identified by 'root';
GRANT ALL PRIVILEGES ON *.* TO 'root1'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION; #授权新用户
flush privileges; #刷新权限