zoukankan      html  css  js  c++  java
  • CentOS7.5二进制安装MySQL-5.6.40

    安装依赖

    yum install -y gcc gcc-c++ automake autoconf
    
    yum -y install cmake bison-devel ncurses-devel libaio-devel
    

    mysql-5.6.40二进制包下载地址

    https://downloads.mysql.com/archives/get/file/mysql-5.6.40-linux-glibc2.12-x86_64.tar.gz
    

    1.下载MySQL-5.6.40二进制包

    [root@7-test1 ~]# wget https://downloads.mysql.com/archives/get/file/mysql-5.6.40-linux-glibc2.12-x86_64.tar.gz
    

    2.解压缩mysql二进制包到/usr/local

    [root@7-test1 ~]# tar xf mysql-5.6.40-linux-glibc2.12-x86_64.tar.gz -C /usr/local
    

    3.修改名称、做软连接

    [root@7-test1 ~]# cd /usr/local
    [root@7-test1 local]# mv mysql-5.6.40-linux-glibc2.12-x86_64 mysql-5.6.40
    [root@7-test1 local]# ln -s mysql-5.6.40 mysql
    

    4.创建mysql用户和组

    //创建mysql组

    [root@7-test1 local]# groupadd mysql
    

    //创建mysql用户

    [root@7-test1 local]# useradd -g mysql -s /bin/false mysql
    

    5.拷贝主配置文件

    //备份/etc/my.cnf

    [root@7-test1 local]# mv /etc/my.cnf /etc/my.cnf.old
    

    //拷贝主配置文件

    [root@7-test1 ~]# cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf
    

    6.拷贝启动脚本

    [root@7-test1 ~]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
    

    7.初始化mysql

    //进入/usr/local/mysql/scripts

    [root@7-test1 ~]# cd /usr/local/mysql/scripts
    

    //初始化前安装依赖包

    [root@test1 scripts]# yum -y install autoconf
    

    //初始化mysql

    [root@7-test1 scripts]# ./mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
    
    --user 		#指定mysql用户
    
    --basedir 		#指定mysql安装目录
    
    --datadir		#指定mysql数据目录
    

    初始化报错

    [root@7-test1 scripts]# ./mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
    
    FATAL ERROR: please install the following Perl modules before executing ./mysql_install_db:
    
    Data::Dumper
    

    原因:缺少autoconf依赖包

    解决方法

    [root@7-test1 scripts]# yum -y install autoconf
    

    8.添加mysql命令环境变量

    //导出mysql命令环境变量

    [root@7-test1 scripts]# echo "export PATH=/usr/local/mysql/bin:$PATH" > /etc/profile.d/mysql.sh
    

    //使配置生效

    [root@7-test1 scripts]# source /etc/profile
    

    9.配置systemd管理mysql

    [root@7-test1 scripts]# vim /etc/systemd/system/mysqld.service
    [Unit]
    Description=MySQL Server
    Documentation=man:mysqld(8)
    Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html
    After=network.target
    After=syslog.target
    [Install]
    WantedBy=multi-user.target
    [Service]
    User=mysql
    Group=mysql
    ExecStart=/usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf
    LimitNOFILE = 5000
    

    10.启动mysql、检查启动

    //启动mysql

    [root@7-test1 scripts]# systemctl start mysqld ; systemctl enable mysqld
    
    [root@7-test1 scripts]# netstat -ntpl  | grep 3306
    
    tcp6       0      0 :::3306                 :::*                    LISTEN      31349/mysqld  
    

    11.进入mysql并设置密码

    //设置mysql密码

    mysql> set password=password('123');
    
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> flush privileges;
    
    Query OK, 0 rows affected (0.01 sec)
    
  • 相关阅读:
    PHP编程资源
    JSP+Java编程资源
    Word、Excel办公书的资源下载
    听你说
    一些好看的渐变色(配色)网站推荐
    js判断数组中是否包含某个元素
    你才是你故事的作者
    vue-color 颜色选择器插件用法介绍
    vue-cli3 导入.md文件,vue中markdown文件的解析与渲染
    新版 animate.css 在vue中的正确使用
  • 原文地址:https://www.cnblogs.com/zeq912/p/10188972.html
Copyright © 2011-2022 走看看