zoukankan      html  css  js  c++  java
  • Cent OS 6.4安装mysql

    Cent OS6.4 RPM安装mysql

    一、卸载掉原有mysql

    因为目前主流Linux系统版本基本上都集成了mysql数据库在里面

    如下命令来查看我们的操作系统上是否已经安装了mysql数据库

    [root@xiaoluo ~]# rpm -qa | grep mysql  // 这个命令就会查看该操作系统上是否已经安装了mysql数据库

    有的话,我们就通过 rpm -e 命令 或者 rpm -e --nodeps 命令来卸载掉

    [root@xiaoluo ~]# rpm -e mysql  // 普通删除模式
    [root@xiaoluo ~]# rpm -e 已经安装的包和库文件--nodeps mysql  // 强力删除模式,如果使用上面命令删除时,提示有依赖的其它文件,则用该命令可以对其进行强力删除

    全部删除

    在删除完以后我们可以通过 rpm -qa | grep mysql 命令来查看mysql是否已经卸载成功!!

    二、下载最新Mysql

    http://dev.mysql.com/downloads/mysql/ 打开网址: Select Platform: 选择 Linux-Generic

    三、安装

    tar -xf MySQL-5.6.22-1.linux_glibc2.5.x86_64.rpm-bundle.tar

    rpm –ivh MySQL-server-5.6.26-1.linux_glibc2.5.x86_64.rpm MySQL-client-5.6.26-1.linux_glibc2.5.x86_64.rpm MySQL-devel-5.6.26-1.linux_glibc2.5.x86_64.rpm

    等待安装完成

    启动mysql服务

    service mysql start   
    Starting MySQL.......... SUCCESS! 

    如果启动失败centos请检查

    /etc/selinux/config

    将SELINUX=enforcing设置为

    SELINUX=disabled

    输入mysql

    新装好的mysql在进入mysql工具时,总是有错误提示:
    # mysql -u root -p
    Enter password:
    ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
    或者
    # mysql -u root -p password 'newpassword'
    Enter password:
    mysqladmin: connect to server at 'localhost' failed
    error: 'Access denied for user 'root'@'localhost' (using password: YES)' 方法操作很简单,如下:
    # /etc/init.d/mysql stop
    # mysqld_safe --user=mysql --skip-grant-tables  --skip-networking

    新开一个SSH窗口
    # mysql -u root mysql

    提示输入密码,直接回车进入

    use mysql
    mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root' and host='root' or host='localhost';//把空的用户密码都修改成非空的密码就行了。
    mysql> FLUSH PRIVILEGES;
    mysql> quit # /etc/init.d/mysqld restart
    # mysql -uroot -p

    Enter password: <输入新设的密码newpassword>

     

    MySql5.6操作时报错:You must SET PASSWORD before executing this statement解决

    mysql>  SET PASSWORD = PASSWORD('123456');
    Query OK, 0 rows affected (0.03 sec)

    也就是用mysql>  SET PASSWORD = PASSWORD('123456');这句话重新设置一次密码!

    设置开机自动启动MySQL

    chkconfig mysql on
    即可设置成功。

     

  • 相关阅读:
    作业2(4)求m和n之间的和
    作业2(3)计算x的n次方
    作业3(6)查询水果的单价。有 4 种水果,苹果(apples)、梨(pears)、桔子(oranges)和葡萄(grapes),
    作业3(5)输入五级制成绩(A-E),输出相应的百分制成绩(0-100)区间,要求使用 switch语句。
    作业3(4)循环输入多个年份 year,判断该年是否为闰年。判断闰年的条件是:能被 4 整除但不能被100 整除,或者能被 400 整除。输入-1退出程序执行
    P39-习题2-5
    P39-习题2-7
    计算N户电费
    P39-习题2-4
    P39-习题2-3
  • 原文地址:https://www.cnblogs.com/liunanjava/p/4743036.html
Copyright © 2011-2022 走看看