美文网首页
Mysql5.7 安装

Mysql5.7 安装

作者: Hyso | 来源:发表于2019-04-15 16:12 被阅读0次
    • 安装依赖
    yum -y install gcc gcc-c++ cmake ncurses-devel bison
    
    • 创建 Mysql 用户及组
    groupadd mysql
    
    useradd mysql -g mysql -s /sbin/nologin -M
    
    • 下载 mysql-boost 安装包
    mkdir -p /usr/local/src/download/mysql5.7
    
    cd /usr/local/src/download/mysql5.7
    
    wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-boost-5.7.25.tar.gz
    
    • 解压 mysql-boost
    tar zxvf mysql-boost-5.7.25.tar.gz
    
    • 创建数据库数据存放目录
    mkdir -p /usr/local/mysql5.7/data
    
    • 创建数据库日志文件
    mkdir -p /usr/local/mysql5.7/log
    
    touch /usr/local/mysql5.7/log/error.log
    
    • 创建数据库 pid 文件存放目录
    mkdir -p /usr/local/mysql5.7/run
    
    • 调整 mysql 目录权限
    chown -R mysql:mysql /usr/local/mysql5.7
    
    • 安装 Mysql5.7
    cd mysql-5.7.25
    
    cmake -DMYSQL_USER=mysql\
     -DCMAKE_INSTALL_PREFIX=/usr/local/mysql5.7\
     -DINSTALL_DATADIR=/usr/local/mysql5.7/data\
     -DMYSQL_UNIX_ADDR=/usr/local/mysql5.7/tmp/mysqld.sock\
     -DDEFAULT_CHARSET=utf8\
     -DDEFAULT_COLLATION=utf8_general_ci\
     -DEXTRA_CHARSETS=all\
     -DWITH_EMBEDDED_SERVER=1\
     -DENABLED_LOCAL_INFILE=1\
     -DWITH_MYISAM_STORAGE_ENGINE=1\
     -DWITH_INNOBASE_STORAGE_ENGINE=1\
     -DDOWNLOAD_BOOST=1\
     -DWITH_BOOST=./boost
    
    make
    
    make install
    
    • mysql 配置文件
    vi /etc/my.cnf
    
    [client]
    port = 3306
    socket = /usr/local/mysql5.7/run/mysql.sock
    
    [mysqld]
    basedir = /usr/local/mysql5.7
    datadir = /usr/local/mysql5.7/data
    socket = /usr/local/mysql5.7/run/mysql.sock
    
    [mysqld_safe]
    log-error =  /usr/local/mysql5.7/log/error.log
    pid-file = /usr/local/mysql5.7/run/mysql.pid
    
    • mysql 启动脚本
    cp mysql.server /etc/init.d/mysqld
    
    chmod a+x /etc/init.d/mysqld
    
    chkconfig --level 345 mysqld on
    
    • 环境变量
    echo "export PATH=/usr/local/mysql5.7/bin:$PATH" >> /etc/profile
    
    source /etc/profile
    
    • 初始化 mysql,得到 root 用户的初始密码
    /usr/local/mysql5.7/bin/mysqld --initialize\
     --basedir=/usr/local/mysql5.7\
     --datadir=/usr/local/mysql5.7/data\
     --user=mysql
    
    • 启动 mysql 服务
    /etc/init.d/mysqld start
    
    • 修改 root 用户密码
    /usr/local/mysql5.7/bin/mysql -uroot -p
    
    alter user 'root'@'localhost' identified by '123456';
    

    相关文章

      网友评论

          本文标题:Mysql5.7 安装

          本文链接:https://www.haomeiwen.com/subject/rimuwqtx.html