安装依赖:

    yum install -y cmake gcc-c++ gcc ncurses-devel perl-Data-Dumper boost boost-doc boost-devel

下载 https://dev.mysql.com/downloads/mysql/

    https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-boost-5.7.27.tar.gz

创建 Mysql 用户及文件目录

    useradd mysql  -s /sbin/nologin
    mkdir -pv /usr/local/mysql/mydata
    mkdir -pv /usr/local/mysql/conf
    chown -R mysql:mysql /usr/local/mysql

编译

    cmake \
    -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
    -DMYSQL_DATADIR=/usr/local/mysql/mydata \
    -DSYSCONFDIR=/usr/local/mysql/conf \
    -DMYSQL_USER=mysql \
    -DWITH_MYISAM_STORAGE_ENGINE=1 \
    -DWITH_INNOBASE_STORAGE_ENGINE=1 \
    -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \
    -DMYSQL_TCP_PORT=3306 \
    -DEXTRA_CHARSETS=all \
    -DDEFAULT_CHARSET=utf8mb4 \
    -DDEFAULT_COLLATION=utf8mb4_unicode_ci \
    -DWITH_DEBUG=0 \
    -DMYSQL_MAINTAINER_MODE=0 \
    -DWITH_SSL:STRING=bundled \
    -DWITH_ZLIB:STRING=bundled \
    -DDOWNLOAD_BOOST=1 \
    -DWITH_BOOST=./boost

安装:make && make install

配置文件:/etc/my.cnf

    [mysqld]
    datadir=/usr/local/mysql/mydata
    socket=/usr/local/mysql/mysql.sock
    character-set-server = utf8mb4
    collation-server = utf8mb4_general_ci

    # 打开binlog日志功能
    log_bin=/usr/local/mysql/binlog/mysql-bin

    #skip-grant-tables 可以免密码登入mysql
    [mysql]
    default-character-set = utf8mb4
    [client]
    default-character-set = utf8mb4

初始化 mysqld:

    /usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/mydata --explicit_defaults_for_timestamp=true

启动: /usr/local/mysql/support-files/mysql.server start 启动: /usr/local/mysql/bin/mysqld_safe –datadir=/usr/local/mysql/mysqldata

开机启动:

    cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
    chmod +x /etc/init.d/mysqld&&chkconfig --add mysqld&&chkconfig mysqld on

启动service mysqld start

    root@localhost: E3otoB:4*38V

更改密码(当前登入用户):

    SET PASSWORD = PASSWORD('....');