美文网首页
centos7手动安装mysql5.6

centos7手动安装mysql5.6

作者: Vanderfan | 来源:发表于2019-10-30 22:57 被阅读0次

    1、环境说明

    操作系统:centos7.5

    MySQL版本:mysql5.6

    2、具体步骤

    1.官网(https://dev.mysql.com/downloads/mysql/)下载mysql5.6.46安装包

    wget https://cdn.mysql.com//Downloads/MySQL-5.6/mysql-5.6.46-linux-glibc2.12-x86_64.tar.gz

    2.安装包解压

    tar -zxvf mysql-5.6.46-linux-glibc2.12-x86_64.tar.gz

    3.目录重命名

    mv mysql-5.6.46-linux-glibc2.12-x86_64 /usr/local/mysql5.6

    4.创建mysql用户和组

    groupadd mysql

    useradd -r -g mysql mysql -d /usr/local/mysql5.6

    5.修改目录权限

    chown -R mysql:mysql /usr/local/mysql5.6

    6.安装数据库

    切换到mysql:     su mysql

    执行:/usr/local/mysql5.6/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql5.6 --datadir=/usr/local/mysql5.6/data

    7.复制mysql配置文件

    cd /usr/local/mysql5.6/support-files

    cp my-default.cnf /etc/my.cnf

    8.添加系统服务

    cp mysql.server /etc/init.d/mysql

    chkconfig mysql on

    9.添加环境变量

    vi /etc/profile

    在最下面添加

    export MYSQL_HOME=/usr/local/mysql5.6

    export PATH=$PATH:$MYSQL_HOME/bin

    保存退出后,执行生效代码

    source /etc/profile

    10.设置默认端口

    vi /etc/my.cnf

    [mysqld]

    basedir=/usr/local/mysql5.6

    datadir=/usr/local/mysql5.6/data

    port=3306

    server_id=1

    socket=/tmp/mysql.sock

    11.编辑mysql启动脚本

    vi /etc/init.d/mysql

    basedir=/usr/local/mysql5.6

    datadir=/usr/local/mysql5.6/data

    12.启动mysql

    service mysql start

    13.设置root密码

    mysqladmin -u root password '123456'

    14.允许所有外部链接访问(可选)

    mysql -u root -p

    mysql命令行输入

    GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;

    FLUSH PRIVILEGES;

    相关文章

      网友评论

          本文标题:centos7手动安装mysql5.6

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