zoukankan      html  css  js  c++  java
  • Linux下安装Mysql

    Mysql5.6安装
    (1) 拷贝mysql-5.6.42-linux-glibc2.12-x86_64.tar.gz
    (2) tar -xvf mysql-5.6.42-linux-glibc2.12-x86_64.tar.gz
    (3) 改名 mv mysql-5.6.42-linux-glibc2.12-x86_64 mysql
    (4) 安装依赖包。 yum install autoconf libaio
    (5) 添加用户和组,修改权限。 groupadd mysql; useradd -g mysql mysql ; chown -R mysql:mysql ./。 【/usr/local/mysql】

      注意,/var/下面的文件或文件夹也需要创建修改权限:

      创建/var/log/mariadb/mariadb.log 且执行chown -R mysql:mysql ,   chmod 777 当前目录;

      创建/var/lib/mysql目录,修改所有者


    (6) 修改配置文件 my.cnf 【如果没有my.cnf,那么手动创建一个即可】

    # For advice on how to change settings please see
    # http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
    
    [mysqld]
    #skip-grant-tables
    # 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=/usr/local/mysql
    datadir=/usr/local/mysql/data
    port=3306
    #server_id=
    socket=/var/lib/mysql/mysql.sock
    log-error=/usr/local/mysql/data/error.log
    pid-file=/usr/local/mysql/mysql.pid
    
    # 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 
    
    sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 

    (7) 初始化数据库
    ./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data/ --pid-file=/usr/local/mysql/mysql.pid
    (8) 添加服务到etc目录
    cp support-files/mysql.server /etc/init.d/mysql
    (9) 启动服务
    service mysql start

     (10)修改相关连接配置

    进入到 /usr/local/mysql/bin目录 执行 ./mysql -h127.0.0.1 -uroot -p

    执行相关密码权限操作

     连接数据库时,注意用自己配置的密码。 同时,如果是阿里云服务器,要修改安全组规则,添加出规则和入规则

  • 相关阅读:
    程序员的7中武器
    需要强化的知识
    微软中国联合小i推出MSN群Beta 不需任何插件
    XML Notepad 2006 v2.0
    Sandcastle August 2006 Community Technology Preview
    [推荐] TechNet 广播 SQL Server 2000完结篇
    《太空帝国 4》(Space Empires IV)以及 xxMod 英文版 中文版 TDM Mod 英文版 中文版
    IronPython 1.0 RC2 更新 1.0.60816
    Microsoft .NET Framework 3.0 RC1
    《Oracle Developer Suite 10g》(Oracle Developer Suite 10g)V10.1.2.0.2
  • 原文地址:https://www.cnblogs.com/greys/p/10876914.html
Copyright © 2011-2022 走看看