现在的位置: 首页 > 综合 > 正文

CentOS6.3x86_64下安装MySQL5.6.11-1(rpm包的方式)

2014年03月23日 ⁄ 综合 ⁄ 共 1912字 ⁄ 字号 评论关闭

一、下载MySQL的rpm包,一般有三个

二、查看并删除已有的mysql依赖包mysql-libs

    查看是否有mysql-libs包:rpm -qa | grep mysql
    如果有,则删除:rpm -e mysql-libs --nodeps

三、安装rpm包

    rpm -ivh MySQL-server-5.6.11-1.el6.x86_64.rpm,必须注意
 
   默认的随机密码在"/root/.mysql_secret"文件中
    rpm -ivh MySQL-client-5.6.11-1.el6.x86_64.rpm
    rpm -ivh MySQL-devel-5.6.11-1.el6.x86_64.rpm
    至此,mysql安装完毕。

四、配置

    1、设置密码

        1)启动mysql服务:service mysql start
   查看mysql是否正在运行:service mysql status
   停止mysql服务:service mysql stop
   重启mysql服务:service mysql restart
        2)进入mysql
              mysql -u root -p
              输入密码:"此密码为上面文件的随机密码"
        3)进入后设置新密码:
              set password = password('新密码'),如:123456

    2、设置开机启动项   

        默认mysql是开机自启动的
       
        可以设置为默认不启动:
        chkconfig --level 2345 mysql off

    3、设置表不区分大小写

        1)在/usr/share/mysql目录下拷贝my-default.cnf文件到/etc目录下,并重命名为my.cnf
            cp /usr/share/my-default.cnf /etc/my.cnf
        2)编辑my.cnf文件,在[mysqld]下面添加:lower_case_table_names=1,重启服务
             

     4、设置mysql默认编码为utf-8

           1)进入mysql,查看mysql当前的默认编码:show variables like 'character_set%';
               
            2)编辑my.cnf文件,在[mysqld]下面添加:default-character-set=utf8
                ,然后重启服务
            3)然后再次查看
               

五、补充(MySQL5.5.31-2的安装)

       安装命令与上述相同,但安装后日志是
      

   PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
   To do so, start the server, then issue the following commands:

   /usr/bin/mysqladmin -u root password 'new-password'
   /usr/bin/mysqladmin -u root -h localhost.localdomain password 'new-password'

   Alternatively you can run:
   /usr/bin/mysql_secure_installation

   which will also give you the option of removing the test
   databases and anonymous user created by default.  This is
   strongly recommended for production servers.

   See the manual for more instructions.

   Please report any problems with the /usr/bin/mysqlbug script!

       所以安装完成后更改密码: /usr/bin/mysqladmin -u root password 'new-password'

抱歉!评论已关闭.