mysql 5.7 linux下的安装

mysql 5.7 linux下的安装

下载地址

    http://dev.mysql.com/downloads/mysql/
    或者
    https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.31-linux-glibc2.12-x86_64.tar.gz

解压缩

    #解压
    tar -zxvf mysql-5.7.31-linux-glibc2.12-x86_64.tar.gz
    #删除原有包
    rm -rf mysql-5.7.31-linux-glibc2.12-x86_64.tar.gz
    #修改文件夹名称
    mv mysql-5.7.31-linux-glibc2.12-x86_64 mysql

添加mysql用户

    groups mysql
    groupadd mysql
    useradd -r -g mysql mysql
    groups mysql
    cd mysql/
    chown -R mysql:mysql ./
    cp -ar mysql /usr/local

安装

    cd /usr/local/mysql
    ./mysqld --initialize --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data
    临时root密码会在 安装日志中打印出来

启动

    配置
    vim /etc/my.cng
        [mysqld]
        datadir=/usr/local/mysql/data
        socket=/usr/local/mysql/data/mysql.sock
        user=mysql
        # Disabling symbolic-links is recommended to prevent assorted security risks
        symbolic-links=0
        
        [mysqld_safe]
        log-error=/usr/local/mysql/logs/mysqld.log
        pid-file=/usr/local/mysql/logs/mysqld.pid
    
    cd /usr/local/mysql/
    ./mysql.server start
    ./support-files/mysql.server start

配置环境变量

    vim /etc/profile
        export MYSQL_HOME=/usr/local/mysql
        export PATH=$PATH:$MYSQL_HOME/bin

登录并设置密码权限等

    mysql -uroot -hlocalhost.localdomain -p
    mysql> set password=password('root')
    mysql>  flush privileges;
    mysql>  grant all privileges on *.* to root@'%' identified by 'root';
    mysql>  flush privileges;

加入services 开机启动

    cp support-files/mysql.server /etc/init.d/mysqld 
    chkconfig --add mysqld 
    chkconfig mysqld on 
    service mysqld restart  
    service mysqld status

tips 如果报错

    报错内容
    /usr/local/mysql/bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
    解决
    yum install libaio
    
    报错内容
    ./mysqld: error while loading shared libraries: libnuma.so.1: cannot open shared object file: No such file or directory
    解决
    yum -y install numactl.x86_64

你可能感兴趣的:(mysql 5.7 linux下的安装)