1. 安装依赖

        yum install -y  gcc gcc-c++ cmake ncurses ncurses-devel bison

2.添加用户

        groupadd mysql
        useradd -s /bin/bash -m -g mysql mysql

3.建立目录并更改用户和组都为mysql

        chown mysql:mysql -R /usr/local/mysql

 4.解压源文件包到/usr/local/mysql中      

        tar -zxvf mysql-boost-5.7.25.tar.gz -C /usr/local/mysql/

 5.cmake进行编译

        cmake -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_BOOST=boost

 6.make && make install

 7.vi /etc/my.cnf 

[mysqld]
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
log-error=/usr/local/mysql/data/saas-db.err
pid-file=/usr/local/mysql/data/saas-db.pid
lower_case_table_names=1
wait_timeout=600
interactive_timeout=600
max_connections=1000
#skip-grant-tables
character-set-server=utf8
server_id=2
log_bin = mysql-bin
binlog_format = ROW
expire_logs_days = 30
max_allowed_packet = 500M
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
[client]
default-character-set=utf8

8.更改安装目录所属

      mkdir /usr/local/mysql/data

       chown -R mysql:mysql  /usr/local/mysql

 9.初始化mysql,必须保证/data/mysql/data是空目录且有权限

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

 10.启动mysql

       service mysqld start

 11.登陆mysql,不用密码

        ./mysql -hlocalhost -uroot -p

        设置开机自启 systemctl enable mysqld

02-24 22:57