linux中mysql的安装

0 oracle官网上下载的mysql有以下几个rpm包
1 查询服务器上已经安装的mysql
rpm -aq | grep mysql    

    mysql-5.0.77-3.el5
    mysql-server-5.0.77-3.el5
    libdbi-dbd-mysql-0.8.1a-1.2.2
    mysql-connector-odbc-3.51.26r1127-1.el5
    mysql-5.0.77-3.el5

    ---
    qt-mysql-4.6.2-25.el6.x86_64

    mysql-connector-odbc-5.1.5r1144-7.el6.x86_64
    mysql-bench-5.1.66-2.el6_3.x86_64
    mysql-devel-5.1.66-2.el6_3.x86_64
    libdbi-dbd-mysql-0.8.3-5.1.el6.x86_64
    mysql-test-5.1.66-2.el6_3.x86_64
    mysql-libs-5.1.66-2.el6_3.x86_64
    mysql-5.1.66-2.el6_3.x86_64
    mysql-connector-java-5.1.17-6.el6.noarch
    mysql-server-5.1.66-2.el6_3.x86_64
2 卸载旧的版本
    rpm -e mysql --nodeps --allmatches (不理会依赖关系,删除所有上一步查出来的相同的mysql)

    [root@localhost home]#  rpm -e mysql-connector-odbc-3.51.26r1127-1.el5 --nodeps --allmatches
    [root@localhost home]#  rpm -e libdbi-dbd-mysql-0.8.1a-1.2.2 --nodeps --allmatches
    [root@localhost home]#  rpm -e mysql-server-5.0.77-3.el5 --nodeps --allmatches

    [root@localhost home]# rpm -aq | grep mysql
    [root@localhost home]# 
3 将老版本的几个文件手工删除
    #rm -f /etc/my.cnf
    #rm -rf /var/lib/mysql
    #rm -rf/var/share/mysql
    # rm -rf/usr/bin/mysql*
4 上传mysql的安装包
    MySQL-client-advanced-5.6.20-1.el6.x86_64.rpm
    MySQL-devel-advanced-5.6.20-1.el6.x86_64.rpm
    MySQL-server-advanced-5.6.20-1.el6.x86_64.rpm
5 安装服务器和客户端
    #rpm -ivh MySQL-server-advanced-5.6.****-1.el6.x86_64.rpm

        A RANDOM PASSWORD HAS BEEN SET FOR THE MySQL root USER !
        You will find that password in '/root/.mysql_secret'.

        You must change that password on your first connect,
        no other statement but 'SET PASSWORD' will be accepted.
        See the manual for the semantics of the 'password expired' flag.

        Also, the account for the anonymous user has been removed.

        In addition, you can run:

          /usr/bin/mysql_secure_installation

        which will also give you the option of removing the test database.
        This is strongly recommended for production servers.

        See the manual for more instructions.

        Please report any problems at http://bugs.mysql.com/

        The latest information about MySQL is available on the web at

          http://www.mysql.com

        Support MySQL by buying support/licenses at http://shop.mysql.com

        New default config file was created as /usr/my.cnf and
        will be used by default by the server when you start it.
        You may edit this file to change server settings

    #rpm -ivh MySQL-client-advanced-5.6.****-1.el6.x86_64.rpm
    说明:不安装mysql-client是不能使用mysql工具登陆到mysql数据库
6 oracle收购Mysql后,新版的mysql刚安装完mysql后不能直接输入mysql登录数据库,
而是设置了默认free password密码,默认密码放在了/root/.mysql_secret文件中,登陆后需要修改密码
7 修改密码
(1)查看文件寻找密码
    vi /root/.mysql_secret
(2)登陆Mysql
        linux mysql 服务启动和关闭 
            service mysql start         service mysql stop

    登陆服务器
        mysql -u root -p
(3)修改密码
        mysql> set password=password('123456') ; 

        也可以使用脚本 /usr/bin/mysql_secure_installation进行交互式的修改mysql的root密码
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值