linux卸载安装mysql_linux 卸载、安装mysql

系统:centos 5.5  32位系统

一、卸载

1、查找以前是否装有mysql

[root@tom-86-old38 mysql]# rpm -qa|grep -i mysql

perl-DBD-MySQL-3.0007-2.el5

mysql55-mysql-5.5.45-1.el5

mysql55-runtime-1-12.el5

mysql55-mysql-server-5.5.45-1.el5

libmysqlclient15-5.0.95-5.w5

mysql55-1-12.el5

mysql55-mysql-libs-5.5.45-1.el5

2、停止mysql服务、删除之前安装的mysql

[root@tom-86-old38 mysql]# rpm -ev mysql55-1-12.el5

[root@tom-86-old38 mysql]# rpm -ev mysql55-mysql-server-5.5.45-1.el5

[root@tom-86-old38 mysql]# rpm -ev mysql55-mysql-5.5.45-1.el5

[root@tom-86-old38 mysql]# rpm -ev mysql55-mysql-libs-5.5.45-1.el5.i386

[root@tom-86-old38 mysql]# rpm -ev perl-DBD-MySQL-3.0007-2.el5.i386

[root@tom-86-old38 mysql]# rpm -ev libmysqlclient15-5.0.95-5.w5

3、查找之前老版本mysql的目录、并且删除老版本mysql的文件和库

[root@tom-86-old38 mysql]# find / -name mysql

/opt/rh/mysql55/root/var/lib/mysql

/opt/rh/mysql55/root/var/lib/mysql/mysql

/usr/local/php-5.4.13/ext/mysql

/usr/lib/mysql

/usr/bin/mysql

/usr/mysql

删除:

[root@tom-86-old38 mysql]# rm -rf /opt/rh/mysql55/root/var/lib/mysql

[root@tom-86-old38 mysql]# rm -rf /opt/rh/mysql55/root/var/lib/mysql/mysql

[root@tom-86-old38 mysql]# rm -rf /usr/local/php-5.4.13/ext/mysql

[root@tom-86-old38 mysql]# rm -rf /usr/lib/mysql

[root@tom-86-old38 mysql]# rm -rf /usr/bin/mysql

[root@tom-86-old38 mysql]# rm -rf /usr/mysql

网上说下面这个文件需要手动删除,但我这没这个文件~

/etc/my.cnf

4、再次查找机器是否安装mysql

rpm -qa|grep -i mysql

无结果,说明已经卸载彻底、接下来直接安装mysql即可

二、安装

1、文件下载

新建/usr/local/mysql目录

[root@tom-86-old38 local]# mkdir mysql

在当前目录下载文件

分别下载以下三个文件(由于我的机器是32位,下面是32位版本的包,如果你的机器是64位的请下载64位版本):

MySQL-server-5.5.16-1.rhel5.i386.rpm

MySQL-client-5.5.16-1.rhel4.i386.rpm

MySQL-devel-5.5.16-1.rhel4.i386.rpm

在这里使用wget命令使用断点传输的方式将这三个文件下载

[root@tom-86-old38 mysql]# wget -c http://dev.mysql.com/get/Downloads/MySQL-5.5/MySQL-client-5.5.16-1.rhel4.i386.rpm/from/http://mysql.spd.co.il/

[root@tom-86-old38 mysql]# wget -c http://dev.mysql.com/get/Downloads/MySQL-5.5/MySQL-devel-5.5.16-1.rhel4.i386.rpm/from/http://mysql.spd.co.il/

2、文件安装

[root@tom-86-old38 mysql]# rpm -ivh MySQL-server-5.5.16-1.rhel4.i386.rpm MySQL-client-5.5.16-1.rhel4.i386.rpm MySQL-devel-5.5.16-1.rhel4.i386.rpm

rpm包安装的MySQL是不会安装/etc/my.cnf文件的,解决方法,只需要复制/usr/share/mysql目录下的my-huge.cnf文件到/etc目录,并改名为my.cnf即可

cp /usr/share/mysql/my-huge.cnf /etc/my.cnf

3、启动mysql

[root@tom-86-old38 mysql]# /etc/init.d/mysql start

Starting MySQL..                                           [确定]

4、测试进入mysql,修改root密码为123456

[root@tom-86-old38 mysql]#mysql

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 1

Server version: 5.5.16 MySQL Community Server (GPL)

Copyright (c) 2000, 2011, 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>UPDATE mysql.user SET password=PASSWORD('123456') WHERE User='root';

mysql>FLUSH PRIVILEGES;

5、新建用户,修改端口

grant ALL PRIVILEGES on*.* to 'zan365'@'%' identified by 'my...';#所有数据库,所有权限,所有远程地址

grant ALL PRIVILEGES on*.* to 'zan365'@localhost identified by 'my...';#所有数据库,所有权限,控制台

FLUSH PRIVILEGES;

修该mysql端口

编辑/etc/my.cnf,修改端口,

port=3306 (将3306改成你想要的)

/etc/init.d/mysql stop

/etc/init.d/mysql start

开起系统防火墙端口。

vi /etc/sysconfig/IPtables

添加-A RH-Firewall-1-INPUT -m state–state NEW -m tcp -p tcp–dport 3306 -j ACCEPT#(将3306改成你想要的)

(注意添加在-A RH-Firewall-1-INPUT -j REJECT–reject-with icmp-host-prohibited之前,否则可能导致规则不生效)

重启防火墙/etc/init.d/iptables restart

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值