zoukankan      html  css  js  c++  java
  • Mysql5.6的安装部署

    可能需要用到的mysql5.6下载地址

    以及可能需要安装的依赖包

    yum install -y perl-Module-Install.noarch
    yum -y install libaio

    解压

    tar xf mysql-5.6.40-linux-glibc2.12-x86_64.tar.gz
    mv mysql-5.6.40-linux-glibc2.12-x86_64 /usr/local/mysql
    useradd -M -s /sbin/nologin mysql
    cd /usr/local/mysql
    chown -R mysql:mysql ./

    初始化数据库

    ./scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql

    完了之后能看到这些小提示,小白建议看看,主要是一些后续的操作,比如修改密码,配置文件之类的

    配置文件

    这里要注意,初试完数据库后,会发现目录下多了个my.cnf,这个配置文件是跟/etc/my.cnf是不同的,正常来说,启动mysql时会依据/etc/下的配置文件启动,所以可以这样子

    rm -rf /etc/my.cnf
    cp ./my.cnf /etc/

    修改配置文件,其实如果使用默认配置的话,大多数不用改,

    vi /etc/my.cnf
    [mysqld]
    
    # Remove leading # and set to the amount of RAM for the most important data
    # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
    # innodb_buffer_pool_size = 128M
    
    # Remove leading # to turn on a very important data integrity option: logging
    # changes to the binary log between backups.
    # log_bin
    
    # These are commonly set, remove the # and set as required.
    # basedir = .....
    # datadir = .....
     port =3306
    # server_id = .....
    # socket = .....
    
    # Remove leading # to set options mainly useful for reporting servers.
    # The server defaults are faster for transactions and fast SELECTs.
    # Adjust sizes as needed, experiment to find the optimal values.
    # join_buffer_size = 128M
    # sort_buffer_size = 2M
    # read_rnd_buffer_size = 2M

    添加服务

    cp ./support-files/mysql.server /etc/init.d/ #忘记了改名,又重新改的名
    mv /etc/init.d/mysql.server /etc/init.d/mysqld
    chmod +x /etc/init.d/mysqld
    chkconfig --add mysqld
    ln -s /usr/local/mysql/bin/mysql /usr/bin

    然后直接打开就好了

    systemctl status mysqld
    ● mysqld.service - LSB: start and stop MySQL
       Loaded: loaded (/etc/rc.d/init.d/mysqld; bad; vendor preset: disabled)
       Active: inactive (dead)
         Docs: man:systemd-sysv-generator(8)
    
    systemctl start mysqld

    可以看一下端口及进程

    netstat -lnpt
    tcp6       0      0 :::3306                 :::*                    LISTEN      4821/mysqld
    
    ps uax|grep mysql              #在这里我们可以看到pid的文件位置:--pid-file
    root       4713  0.0  0.0 115532  1696 ?        S    17:29   0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/usr/local/mysql/data --pid-file=/usr/local/mysql/data/localhost.localdomain.pid
    mysql      4821  0.2 22.1 1368528 450588 ?      Sl   17:29   0:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=localhost.localdomain.err --pid-file=/usr/local/mysql/data/localhost.localdomain.pid
    

     最后可以修改root密码

    /usr/local/mysql/bin/mysqladmin -u root password '123456'
    Warning: Using a password on the command line interface can be insecure. ps:这只是演示,生产中可不要学我哦!!
    警告:在命令行界面上使用密码可能不安全。
    mysql -uroot -p123456
    Warning: Using a password on the command line interface can be insecure.
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 5
    Server version: 5.6.40 MySQL Community Server (GPL)
    
    Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
    
    Oracle is a registered trademark of Oracle Corporation and/or its
    affiliates. Other names may be trademarks of their respective
    owners.
    
    Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
    
    mysql> quit
    Bye
    本帖子也是纯手工制作,转载请标明出处-----------burukku(づ。◕ᴗᴗ◕。)づ
  • 相关阅读:
    HDOJ 1207 汉诺塔II
    [转]写代码的小女孩
    POJ Subway tree systems
    HDOJ 3555 Bomb (数位DP)
    POJ 1636 Prison rearrangement (DP)
    POJ 1015 Jury Compromise (DP)
    UVA 10003
    UVA 103 Stacking Boxes
    HDOJ 3530 Subsequence
    第三百六十二、三天 how can I 坚持
  • 原文地址:https://www.cnblogs.com/yuan9910/p/13955101.html
Copyright © 2011-2022 走看看