• centos7 二进制安装包安装 mysql5.6


    centos7 二进制安装包安装 mysql5.6

    一、下载mysql5.6二进制安装包

    http://mirrors.sohu.com/mysql/MySQL-5.6/

    如:mysql-5.6.34-linux-glibc2.5-x86_64.tar.gz

    二、安装mysql5.6(安装在/data/mysql56)

    (1)、创建mysql用户账号

    > useradd -s /sbin/nologin -M mysql
    


    (2)、解压压缩包

    > tar xf mysql-5.6.34-linux-glibc2.5-x86_64.tar.gz
    

     
    (3)、重命名

    > mv mysql-5.6.34-linux-glibc2.5-x86_64 mysql56
    

     
    (4)、复制配置文件

    > cp /data/mysql56/support-files/my-default.cnf /etc/my.cnf

    修改配置文件

    [client]
    port = 3306
    socket = /data/mysql56/mysql.sock
    default-character-set = utf8
    [mysqld]
    skip-name-resolve
    user = mysql
    basedir = /data/mysql56
    datadir = /data/mysql56/data
    port = 3306
    server_id = 10
    socket = /data/mysql56/mysql.sock
    pid-file = /data/mysql56/mysql.pid
    log-error = /data/mysql56/data/mysql.err
    log-bin = /data/mysql56/data/mysql-bin
    character-set-server = utf8
    

    (*二进制安装,默认配置文件在/etc/my.cnf)

    (5)、初始化数据库

    > chown -R mysql.mysql /data/mysq56
    > /data/mysql56/scripts/mysql_install_db 
    --defaults-file=/etc/my.cnf 
    --user=mysql 
    --basedir=/data/mysql56 
    --datadir=/data/mysql56/data

    如果出现如下信息

    FATAL ERROR: please install the following Perl modules before executing
    Data::Dumper
    
    > yum -y install autoconf

    此包安装时会安装Data:Dumper模块

    三、配置并启动mysql

    > cp /data/mysql56/support-files/mysql.server /etc/init.d/mysqld
    > chmod 755 /etc/init.d/mysqld

    (*注意,mysql二进制安装默认的路径为/usr/local/mysql,启动脚本里/usr/local/mysql需要替换)

    > sed -i 's#/usr/local/mysql#/data/mysql56#g' /data/mysql56/bin/mysqld_safe /etc/init.d/mysqld

    启动mysql

    > service mysqld start
    

     
    四、添加自启动

    > chkconfig --add mysqld
    > chkconfig mysqld on
    > chkconfig --list mysqld
    

     
    五、配置环境变量

    > echo 'export PATH=/data/mysql56/bin:$PATH' >> /etc/profile
    > source /etc/profile
    

     
    六、修改mysql密码(mysql5.6安装默认root密码为空)

    > mysqladmin -u root password '123456'


    七、清理无用的mysql用户及库
    登陆mysql

    > mysql -uroot -p

    查询用户

    > select user,host from mysql.user;

    如下所示

    +------+-----------------------+
    | user | host                  |
    +------+-----------------------+
    | root | 127.0.0.1             |
    | root | ::1                   |
    |      | localhost             |
    | root | localhost             |
    |      | localhost.localdomain |
    | root | localhost.localdomain |
    +------+-----------------------+
    > drop user "root"@"::1";
    > drop user ""@"localhost";
    > drop user ""@"localhost.localdomain";
    > drop user "root"@"localhost.localdomain";

    删除无用库

    > drop database test;
    



  • 相关阅读:
    Vue项目碰到"‘webpack-dev-server’不是内部或外部命令,也不是可运行的程序或批处理文件"报错
    PowerDesigner最基础的使用方法入门学习
    Centos7 上安装mysql遇上的问题:mysql无法正常启动
    微信小程序的Web API接口设计及常见接口实现
    模型数据作渲染优化时遇到的问题
    vertex compression所遇到的问题
    depth and distance
    Linear or non-linear shadow maps?
    实施vertex compression所遇到的各种问题和解决办法
    【转】編譯Ogre1.9 IOS Dependencies及Ogre Source步驟及相關注意事項…
  • 原文地址:https://www.cnblogs.com/jkko123/p/6357539.html
Copyright © 2020-2023  润新知