Chinaunix首页 | 论坛 | 博客
  • 博客访问: 27425
  • 博文数量: 6
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 56
  • 用 户 组: 普通用户
  • 注册时间: 2014-04-24 09:37
个人简介

生活就是被生下来,然后自己活下去!

文章分类

全部博文(6)

文章存档

2016年(2)

2015年(2)

2014年(2)

分类: Mysql/postgreSQL

2014-11-18 16:07:05

    背景介绍:系统版本 centos6.5而且能上网  MySQL版本5.6.20

     

    1.检查MySQL及相关的rpm包安装情况

    [root@mysql1 ~]# rpm -qa |grep -i mysql

    mysql-libs-5.1.71-1.el6.x86_64

     

    2.如果有,卸载MySQL

    [root@mysql1 ~]# yum -y remove mysql-libs*

    Loaded plugins: fastestmirror, refresh-packagekit, security

    Setting up Remove Process

    Resolving Dependencies

    --> Running transaction check

    ---> Package mysql-libs.x86_64 0:5.1.71-1.el6 will be erased

    --> Processing Dependency: libmysqlclient.so.16()(64bit) for package: 2:postfix-2.6.6-2.2.el6_1.x86_64

    --> Processing Dependency: libmysqlclient.so.16(libmysqlclient_16)(64bit) for package: 2:postfix-2.6.6-2.2.el6_1.x86_64

    ………………

    Dependency Removed:

      cronie.x86_64 0:1.4.4-12.el6                       cronie-anacron.x86_64 0:1.4.4-12.el6             

      crontabs.noarch 0:1.10-33.el6                      postfix.x86_64 2:2.6.6-2.2.el6_1                 

      redhat-lsb.x86_64 0:4.0-7.el6.centos               redhat-lsb-compat.x86_64 0:4.0-7.el6.centos      

      redhat-lsb-core.x86_64 0:4.0-7.el6.centos          redhat-lsb-graphics.x86_64 0:4.0-7.el6.centos    

      redhat-lsb-printing.x86_64 0:4.0-7.el6.centos      sysstat.x86_64 0:9.0.4-22.el6                    

     

    Complete!

     

    3.将MySQL官网下载的rpm包上传的指定的目录下

    我这里的目录是/software

    [root@mysql1 software]# ls

    MySQL-5.6.20-1.linux_glibc2.5.i386.rpm-bundle.tar

     

    由于我 的software目录下只有一个包,所以用*

    4.解压MySQL

    [root@mysql1 software]# tar -xvf *

    MySQL-embedded-5.6.20-1.linux_glibc2.5.i386.rpm

    MySQL-server-5.6.20-1.linux_glibc2.5.i386.rpm

    MySQL-devel-5.6.20-1.linux_glibc2.5.i386.rpm

    MySQL-shared-compat-5.6.20-1.linux_glibc2.5.i386.rpm

    MySQL-client-5.6.20-1.linux_glibc2.5.i386.rpm

    MySQL-shared-5.6.20-1.linux_glibc2.5.i386.rpm

    MySQL-test-5.6.20-1.linux_glibc2.5.i386.rpm

     

    (用yum install的原因是MySQL的各个包之间有依赖关系,在MySQL5.6.20这个版本是这样的,但在5.6.14版本似乎没有这个问题,这可能与MySQL版本有关,现在暂时是这么猜想的)

    5.安装MySQL

    [root@mysql1 software]# yum install *  

    Loaded plugins: fastestmirror, refresh-packagekit, security

    Determining fastest mirrors

     * base: mirrors.yun-idc.com

     * extras: mirrors.yun-idc.com

     * updates: mirrors.yun-idc.com

    Setting up Install Process

    No package MySQL-5.6.20-1.linux_glibc2.5.i386.rpm-bundle.tar available.

    Examining MySQL-client-5.6.20-1.linux_glibc2.5.i386.rpm: MySQL-client-5.6.20-1.linux_glibc2.5.i386

    Marking MySQL-client-5.6.20-1.linux_glibc2.5.i386.rpm to be installed

    Examining MySQL-devel-5.6.20-1.linux_glibc2.5.i386.rpm: MySQL-devel-5.6.20-1.linux_glibc2.5.i386

    Marking MySQL-devel-5.6.20-1.linux_glibc2.5.i386.rpm to be installed

    Examining MySQL-embedded-5.6.20-1.linux_glibc2.5.i386.rpm: MySQL-embedded-5.6.20-1.linux_glibc2.5.i386

    Marking MySQL-embedded-5.6.20-1.linux_glibc2.5.i386.rpm to be installed

    Examining MySQL-server-5.6.20-1.linux_glibc2.5.i386.rpm: MySQL-server-5.6.20-1.linux_glibc2.5.i386

    Marking MySQL-server-5.6.20-1.linux_glibc2.5.i386.rpm to be installed

    Examining MySQL-shared-5.6.20-1.linux_glibc2.5.i386.rpm: MySQL-shared-5.6.20-1.linux_glibc2.5.i386

    Marking MySQL-shared-5.6.20-1.linux_glibc2.5.i386.rpm to be installed

    Examining MySQL-shared-compat-5.6.20-1.linux_glibc2.5.i386.rpm: MySQL-shared-compat-5.6.20-1.linux_glibc2.5.i386

    ……………………

    Total size: 934 M

    Total download size: 25 M

    Is this ok [y/N]: y

    Downloading Packages:

    (1/14): glibc-2.12-1.149.el6.i686.rpm                                           | 4.3 MB     00:07    

    (2/14): glibc-2.12-1.149.el6.x86_64.rpm                                         | 3.8 MB     00:05    

    (3/14): glibc-common-2.12-1.149.el6.x86_64.rpm                                  |  14 MB     00:31    

    (4/14): glibc-devel-2.12-1.149.el6.x86_64.rpm                                   | 983 kB     00:00    

    (5/14): glibc-headers-2.12-1.149.el6.x86_64.rpm                                 | 611 kB     00:00    

    (6/14): libaio-0.3.107-10.el6.i686.rpm                                          |  21 kB     00:00    

    (7/14): libgcc-4.4.7-11.el6.i686.rpm                                            | 113 kB     00:00    

    (8/14): libgcc-4.4.7-11.el6.x86_64.rpm                                          | 102 kB     00:00    

    (9/14): libstdc++-4.4.7-11.el6.i686.rpm                                         | 301 kB     00:00    

    (10/14): libstdc++-4.4.7-11.el6.x86_64.rpm                                      | 294 kB     00:00    

    (11/14): ncurses-libs-5.7-3.20090208.el6.i686.rpm                               | 251 kB     00:00    

    (12/14): nss-softokn-freebl-3.14.3-17.el6.i686.rpm                              | 153 kB     00:00    

    (13/14): nss-softokn-freebl-3.14.3-17.el6.x86_64.rpm                            | 163 kB     00:00    

    (14/14): zlib-1.2.3-29.el6.i686.rpm                                             |  73 kB     00:00    

    -------------------------------------------------------------------------------------------------------

    Total                                                                  494 kB/s |  25 MB     00:52

    ……………………

    Is this ok [y/N]: y

    Running rpm_check_debug

    Running Transaction Test

    Transaction Test Succeeded

    Running Transaction

      Updating   : libgcc-4.4.7-11.el6.x86_64                                                         1/28

      Updating   : glibc-common-2.12-1.149.el6.x86_64                                                 2/28

      Updating   : nss-softokn-freebl-3.14.3-17.el6.x86_64                                            3/28

      Updating   : glibc-2.12-1.149.el6.x86_64                                                        4/28

      Updating   : glibc-headers-2.12-1.149.el6.x86_64                                                5/28

      Installing : MySQL-devel-5.6.20-1.linux_glibc2.5.i386                                           6/28

      Installing : nss-softokn-freebl-3.14.3-17.el6.i686                                              7/28

      Installing : glibc-2.12-1.149.el6.i686                                                          8/28

      Installing : libgcc-4.4.7-11.el6.i686                                                           9/28

      Updating   : glibc-devel-2.12-1.149.el6.x86_64                                                 10/28

      Updating   : libstdc++-4.4.7-11.el6.x86_64                                                     11/28

      Installing : libstdc++-4.4.7-11.el6.i686                                                       12/28

      Installing : ncurses-libs-5.7-3.20090208.el6.i686                                              13/28

      Installing : libaio-0.3.107-10.el6.i686                                                        14/28

      Installing : MySQL-client-5.6.20-1.linux_glibc2.5.i386                                         15/28

      Installing : zlib-1.2.3-29.el6.i686                                                            16/28

      Installing : MySQL-test-5.6.20-1.linux_glibc2.5.i386                                           17/28

      Installing : MySQL-shared-compat-5.6.20-1.linux_glibc2.5.i386                                  18/28

      Installing : MySQL-embedded-5.6.20-1.linux_glibc2.5.i386                                       19/28

      Installing : MySQL-server-5.6.20-1.linux_glibc2.5.i386                                         20/28

    ……………………

    Installed:

      MySQL-client.i386 0:5.6.20-1.linux_glibc2.5     MySQL-devel.i386 0:5.6.20-1.linux_glibc2.5         

      MySQL-embedded.i386 0:5.6.20-1.linux_glibc2.5   MySQL-server.i386 0:5.6.20-1.linux_glibc2.5        

      MySQL-shared.i386 0:5.6.20-1.linux_glibc2.5     MySQL-shared-compat.i386 0:5.6.20-1.linux_glibc2.5 

      MySQL-test.i386 0:5.6.20-1.linux_glibc2.5     

     

    Dependency Installed:

      glibc.i686 0:2.12-1.149.el6                       libaio.i686 0:0.3.107-10.el6                     

      libgcc.i686 0:4.4.7-11.el6                        libstdc++.i686 0:4.4.7-11.el6                    

      ncurses-libs.i686 0:5.7-3.20090208.el6            nss-softokn-freebl.i686 0:3.14.3-17.el6          

      zlib.i686 0:1.2.3-29.el6                        

     

    Dependency Updated:

      glibc.x86_64 0:2.12-1.149.el6                        glibc-common.x86_64 0:2.12-1.149.el6           

      glibc-devel.x86_64 0:2.12-1.149.el6                  glibc-headers.x86_64 0:2.12-1.149.el6          

      libgcc.x86_64 0:4.4.7-11.el6                         libstdc++.x86_64 0:4.4.7-11.el6                

      nss-softokn-freebl.x86_64 0:3.14.3-17.el6

    Complete!

     

    6.初始化MySQL

    [root@mysql1 software]# /usr/bin/mysql_install_db

    Installing MySQL system tables...2014-11-18 23:22:10 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).

    2014-11-18 23:22:10 29388 [Note] InnoDB: Using mutexes to ref count buffer pool pages

    2014-11-18 23:22:10 29388 [Note] InnoDB: The InnoDB memory heap is disabled

    ……………………

     

    7.启动MySQL服务

    [root@mysql1 software]# service mysql start

    Starting MySQL. SUCCESS!

     

    8.查看MySQL root用户的默认密码

    [root@mysql1 software]# cat /root/.mysql_secret

    # The random password set for the root user at Tue Nov 18 23:11:34 2014 (local time): 2wbVUhMchhUv2kNx

    密码为标红的部分

     

    9.登陆MySQL

    [root@mysql1 software]# mysql -uroot -p2wbVUhMchhUv2kNx

    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 2

    Server version: 5.6.20

     

    Copyright (c) 2000, 2014, 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>

     

    10.修改MySQL密码

    mysql> set password = password('asd123');

    Query OK, 0 rows affected (0.00 sec)

     

    11.退出再登陆

    mysql> exit

    Bye

     

    [root@mysql1 software]# mysql -uroot -pasd123

    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 3

    Server version: 5.6.20 MySQL Community Server (GPL)

     

    Copyright (c) 2000, 2014, 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>

     

    12.设置为允许远程登陆

    mysql> select host,user,password from user;

    +-----------+------+-------------------------------------------+

    | host      | user | password                                  |

    +-----------+------+-------------------------------------------+

    | localhost | root | *204C8A3B79DC1533866049F6819865291C5E6AD5 |

    | mysql1    | root | *43A620D07F9FD7FD0BD9C0F9DC988F2DDD5CA73E |

    | 127.0.0.1 | root | *43A620D07F9FD7FD0BD9C0F9DC988F2DDD5CA73E |

    | ::1       | root | *43A620D07F9FD7FD0BD9C0F9DC988F2DDD5CA73E |

    +-----------+------+-------------------------------------------+

    4 rows in set (0.00 sec)

     

    mysql> update user set password=password('asd123')where user='root';

    Query OK, 3 rows affected (0.00 sec)

    Rows matched: 4  Changed: 3  Warnings: 0

     

    mysql> update user set host='%' where user='root'and host='localhost';

    Query OK, 1 row affected (0.00 sec)

    Rows matched: 1  Changed: 1  Warnings: 0

    mysql> flush privileges;

    Query OK, 0 rows affected (0.00 sec)

     

    13.设置为开机自启动(看需要而定)

    [root@mysql1 ~]# chkconfig mysql on

    [root@mysql1 ~]# chkconfig --list |grep mysql

    mysql                  0:off        1:off        2:on        3:on        4:on        5:on        6:off

     

    说明:关于/etc/my.cnf

    在按照以上方法安装完后,my.cnf在/usr/my.cnf

    所以可以做以下操作

    [root@mysql1 ~]# mv /usr/my.cnf  /etc

     

     

    补充:MySQL的默认安装位置

     

    1

    /var/lib/mysql/               #数据库目录

    2

    /usr/share/mysql              #配置文件目录

    3

    /usr/bin                     #相关命令目录

    4

    /etc/init.d/mysql              #启动脚本

     

     

     

    再配置/etc/my.cnf文件,修改数据存放路径、mysql.sock路径以及默认编码utf-8.

     

    1. [client]  
    2. password        = 123456  
    3. port            = 3306  
    1. default-character-set=utf8  
    1. [mysqld]  
    2. port            = 3306  
    1. character_set_server=utf8  
    2. character_set_client=utf8  
    3. collation-server=utf8_general_ci  
    1.  #(注意linux下mysql安装完后是默认:表名区分大小写,列名不区分大小写; 0:区分大小写,1:不区分大小写)  
    1. lower_case_table_names=1  
    1. #(设置最大连接数,默认为 151,MySQL服务器允许的最大连接数16384; )  
    1. max_connections=1000  
    1. [mysql]  
    1. default-character-set = utf8  

     

     

阅读(2967) | 评论(0) | 转发(0) |
0

上一篇:没有了

下一篇:centos查看硬件信息

给主人留下些什么吧!~~