程序员人生 网站导航

linux安装mysql 5.6实时教程和配置

栏目:服务器时间:2015-03-18 10:01:07

今天数据库服务器可使用了,现在下1步就是安装mysql,决定mysql 版本为5.6.14

  1. 检查系统中是不是已安装过mysql。
    rpm -qa | grep mysql
    以下图:

  2. 如果存在,则需要删除。
    yum -y remove mysql*
  3. 继续检查1下是不是还存在mysql
    rpm -qa | grep -i mysql

  4. 然后下1步就是下载rpm包了。需要下载:
    MySQL-client⑸.6.15⑴.el6.x86_64.rpm
    MySQL-devel⑸.6.15⑴.el6.x86_64.rpm
    MySQL-server⑸.6.15⑴.el6.x86_64.rpm

    逐1履行命令:
    wget http://cdn.mysql.com/archives/mysql⑸.6/MySQL-client⑸.6.15⑴.el6.x86_64.rpm
    wget http://cdn.mysql.com/archives/mysql⑸.6/MySQL-devel⑸.6.15⑴.el6.x86_64.rpm
    wget http://cdn.mysql.com/archives/mysql⑸.6/MySQL-server⑸.6.15⑴.el6.x86_64.rpm


  5. 接下来就是安装了分别顺次履行:
    [root@iZ25in7iu0fZ rpm]# rpm -ivh MySQL-server⑸.6.15⑴.el6.x86_64.rpm
    Preparing...                ########################################### [100%]
       1:MySQL-server           ########################################### [100%]
    2015-03-06 08:16:03 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
    2015-03-06 08:16:03 28629 [Note] InnoDB: The InnoDB memory heap is disabled
    2015-03-06 08:16:03 28629 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
    2015-03-06 08:16:03 28629 [Note] InnoDB: Compressed tables use zlib 1.2.3
    2015-03-06 08:16:03 28629 [Note] InnoDB: Using Linux native AIO
    2015-03-06 08:16:03 28629 [Note] InnoDB: Using CPU crc32 instructions
    2015-03-06 08:16:03 28629 [Note] InnoDB: Initializing buffer pool, size = 128.0M
    2015-03-06 08:16:03 28629 [Note] InnoDB: Completed initialization of buffer pool
    2015-03-06 08:16:03 28629 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
    2015-03-06 08:16:03 28629 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
    2015-03-06 08:16:03 28629 [Note] InnoDB: Database physically writes the file full: wait...
    2015-03-06 08:16:03 28629 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
    2015-03-06 08:16:04 28629 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
    2015-03-06 08:16:06 28629 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
    2015-03-06 08:16:06 28629 [Warning] InnoDB: New log files created, LSN=45781
    2015-03-06 08:16:06 28629 [Note] InnoDB: Doublewrite buffer not found: creating new
    2015-03-06 08:16:06 28629 [Note] InnoDB: Doublewrite buffer created
    2015-03-06 08:16:06 28629 [Note] InnoDB: 128 rollback segment(s) are active.
    2015-03-06 08:16:06 28629 [Warning] InnoDB: Creating foreign key constraint system tables.
    2015-03-06 08:16:06 28629 [Note] InnoDB: Foreign key constraint system tables created
    2015-03-06 08:16:06 28629 [Note] InnoDB: Creating tablespace and datafile system tables.
    2015-03-06 08:16:06 28629 [Note] InnoDB: Tablespace and datafile system tables created.
    2015-03-06 08:16:06 28629 [Note] InnoDB: Waiting for purge to start
    2015-03-06 08:16:06 28629 [Note] InnoDB: 5.6.15 started; log sequence number 0
    A random root password has been set. You will find it in '/root/.mysql_secret'.
    2015-03-06 08:16:07 28629 [Note] Binlog end
    2015-03-06 08:16:07 28629 [Note] InnoDB: FTS optimize thread exiting.
    2015-03-06 08:16:07 28629 [Note] InnoDB: Starting shutdown...
    2015-03-06 08:16:08 28629 [Note] InnoDB: Shutdown completed; log sequence number 1625977




    2015-03-06 08:16:08 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
    2015-03-06 08:16:08 28652 [Note] InnoDB: The InnoDB memory heap is disabled
    2015-03-06 08:16:08 28652 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
    2015-03-06 08:16:08 28652 [Note] InnoDB: Compressed tables use zlib 1.2.3
    2015-03-06 08:16:08 28652 [Note] InnoDB: Using Linux native AIO
    2015-03-06 08:16:08 28652 [Note] InnoDB: Using CPU crc32 instructions
    2015-03-06 08:16:08 28652 [Note] InnoDB: Initializing buffer pool, size = 128.0M
    2015-03-06 08:16:08 28652 [Note] InnoDB: Completed initialization of buffer pool
    2015-03-06 08:16:08 28652 [Note] InnoDB: Highest supported file format is Barracuda.
    2015-03-06 08:16:08 28652 [Note] InnoDB: 128 rollback segment(s) are active.
    2015-03-06 08:16:08 28652 [Note] InnoDB: Waiting for purge to start
    2015-03-06 08:16:08 28652 [Note] InnoDB: 5.6.15 started; log sequence number 1625977
    2015-03-06 08:16:08 28652 [Note] Binlog end
    2015-03-06 08:16:08 28652 [Note] InnoDB: FTS optimize thread exiting.
    2015-03-06 08:16:08 28652 [Note] InnoDB: Starting shutdown...
    2015-03-06 08:16:10 28652 [Note] InnoDB: Shutdown completed; log sequence number 1625987



    [root@iZ25in7iu0fZ rpm]# rpm -ivh MySQL-devel⑸.6.15⑴.el6.x86_64.rpm
    Preparing...                ########################################### [100%]
       1:MySQL-devel            ########################################### [100%]
    [root@iZ25in7iu0fZ rpm]# rpm -ivh MySQL-client⑸.6.15⑴.el6.x86_64.rpm
    Preparing...                ########################################### [100%]
       1:MySQL-client           ########################################### [100%]

    修改配置文件位置。
    [root@iZ25in7iu0fZ rpm]# cp /usr/share/mysql/my-default.cnf /etc/my.cnf
  6. 初始化MySQL及设置密码
    cp /usr/share/mysql/my-default.cnf /etc/my.cnf
    /usr/bin/mysql_install_db
    cat /root/.mysql_secret 
    记录最后的密码
    mysql -p ---输入记录的密码,便可登录mysql。
    set password for 'root'@'localhost' =password('新密码');
    flush privileges;
    exit
  7. 设置自启动
    chkconfig mysql on

  8.  MySQL的默许安装位置

    1 /var/lib/mysql/               #数据库目录
    2 /usr/share/mysql              #配置文件目录
    3 /usr/bin                     #相干命令目录
    4 /etc/init.d/mysql              #启动脚本
  9. 修改字符集和数据寄存目录
    原来配置文件:


    更改以后为:

    # For advice on how to change settings please see
    # http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
    # *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
    # *** default location during install, and will be replaced if you
    # *** upgrade to a newer version of MySQL.


    [client]
    port            = 3306
    default-character-set=utf8




    [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 = /mnt/data/mysql
    port = 3306
    # server_id = .....
    # socket = .....


    lower_case_table_names=1


    max_connections=1000


    collation_server = utf8_general_ci
    character_set_server = utf8


    # default-character-set=utf8
    # init_connect='SET NAMES utf8'





    # 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


    [mysql]
    default-character-set = utf8

    注意标红的。


    然后就是修改数据库的数据目录:
    vi /etc/init.d/mysql



  10. 重启数据库


    service mysql restart

  11. 大功告成。


------分隔线----------------------------
------分隔线----------------------------

最新技术推荐