http://www.centoscn.com/CentosServer/sql/2015/0409/5127.html
常用命令
cat /etc/issue
rpm -qa | grep mysql
yum -y remove mysql-libs-5.1*
rpm -ivh MySQL-server-5.6.21-1.rhel5.x86_64.rpm
rpm -ivh MySQL-client-5.6.21-1.rhel5.x86_64.rpm
rpm -ivh MySQL-devel-5.6.21-1.rhel5.x86_64.rpm
cp /usr/share/mysql/my-default.cnf /etc/my.cnf
/usr/bin/mysql_install_db
ps -ef | grep mysql
chkconfig mysql on
chkconfig mysql --list

忘记mysql密码,CentOS下设置Mysql的root密码
/etc/init.d/mysql stop
mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
mysql -u root mysql
UPDATE user SET Password=PASSWORD('newpassword') where USER='root';
FLUSH PRIVILEGES;
exit;
/etc/init.d/mysql restart

如何确定mysql使用哪个配置文件

mysql --help | grep 'Default options' -A 1
按照上面顺序一样,mysql会依序的去这些位置找my.cnf文件的,没有就下一个。
whereis my.cnf可以查看哪些地方有该文件

开启mysql 3306访问端口

/sbin/iptables -I INPUT -p tcp --dport 3306 -j ACCEPT
/etc/rc.d/init.d/iptables save
/etc/init.d/iptables status
即可 -- 卸载mysql

1: 检查是否安装了MySQL组件。

[root@DB-Server init.d]# rpm -qa | grep -i mysql
 
MySQL-devel-5.6.23-1.linux_glibc2.5
 
MySQL-client-5.6.23-1.linux_glibc2.5
 
MySQL-server-5.6.23-1.linux_glibc2.5
 

如上所示,说明安装了MySQL 5.6.23这个版本的client、server、devel三个组件。

2: 卸载前关闭MySQL服务

2.1 方法1

[root@DB-Server init.d]# service mysql status
 MySQL running (25673)[  OK  ]
[root@DB-Server init.d]# service mysql stop
 Shutting down MySQL..[  OK  ]
[root@DB-Server init.d]# service mysql status
 MySQL is not running[FAILED]

2.2 方法2

[root@DB-Server init.d]# ./mysql status
 MySQL running (26215)[  OK  ]
[root@DB-Server init.d]# ./mysql stop
 Shutting down MySQL..[  OK  ]
[root@DB-Server init.d]# ./mysql status
 MySQL is not running[FAILED]
[root@DB-Server init.d]# 

[root@DB-Server init.d]# chkconfig --list | grep -i mysql
 
mysql 0:off 1:off 2:on 3:on 4:on 5:on 6:off
 
[root@DB-Server init.d]# 
 

3. 收集MySQL对应的文件夹信息

[root@DB-Server init.d]# whereis mysql

mysql: /usr/bin/mysql /usr/include/mysql /usr/share/mysql /usr/share/man/man1/mysql.1.gz

最好实用find命令查看MySQL数据库相关的文件,方便后面彻底删除MySQL。

[root@DB-Server init.d]# find / -name mysql
/etc/rc.d/init.d/mysql
/etc/logrotate.d/mysql
/var/lock/subsys/mysql
/var/lib/mysql
/var/lib/mysql/mysql
/usr/include/mysql
/usr/include/mysql/mysql
/usr/bin/mysql
/usr/share/mysql
/usr/lib64/mysql

4: 卸载删除MySQL各类组件

[root@DB-Server init.d]# 
[root@DB-Server init.d]# rpm -ev MySQL-devel-5.6.23-1.linux_glibc2.5
[root@DB-Server init.d]# rpm -ev MySQL-server-5.6.23-1.linux_glibc2.5
You have new mail in /var/spool/mail/root
[root@DB-Server init.d]# rpm -ev MySQL-client-5.6.23-1.linux_glibc2.5
[root@DB-Server init.d]#

5:删除MySQL对应的文件夹

检查各个MySQL文件夹是否清理删除干净。

[root@DB-Server init.d]# whereis mysql
mysql:
[root@DB-Server init.d]# find / -name mysql
/var/lib/mysql
/var/lib/mysql/mysql
/usr/lib64/mysql
[root@DB-Server init.d]# rm -rf /var/lib/mysql
[root@DB-Server init.d]# rm -rf /var/lib/mysql/mysql
[root@DB-Server init.d]# rm -rf /usr/lib64/mysql
[root@DB-Server init.d]# 

6:删除mysql用户及用户组

如果有必要,删除mysql用户以及mysql用户组。

[root@DB-Server ~]# more /etc/passwd | grep mysql
mysql:x:101:501::/home/mysql:/bin/bash
[root@DB-Server ~]# more /etc/shadow | grep mysql
mysql:!!:16496::::::
[root@DB-Server ~]# more /etc/group | grep mysql
mysql:x:501:
[root@DB-Server ~]# userdel mysql
[root@DB-Server ~]# groupdel mysql
groupdel: group mysql does not exist
[root@DB-Server ~]# 

7:确认MySQL是否卸载删除

[root@DB-Server init.d]# rpm -qa | grep -i mysql

-- 转自http://www.cnblogs.com/kerrycode/p/4364465.html

0112centos上面l安装卸载mysq的更多相关文章

  1. 帮同事写了几行代码,在 安装/卸载 程序里 注册/卸载 OCX控件

    写了个小控制台程序,这个程序用来注册 / 卸载OCX控件,用在Inno Setup做的安装卸载程序里. #include "stdafx.h" #include <windo ...

  2. Linux系统Vi/Vim编辑器的简单介绍、安装/卸载、常用命令

    Linux系统Vi/Vim编辑器的简单介绍.安装/卸载.常用命令 1.介绍 vi(Visual Interface)编辑器是Linux和Unix上最基本的文本编辑器,工作在字符模式下.由于不需要图形界 ...

  3. Linux 之【辨析UPDATE/UPGRADE】和安装/卸载软件(apt-get)

    一.[辨析UPDATE/UPGRADE] UPDATE: update is used to download package information from all configured sour ...

  4. debian下使用dpkg来安装/卸载deb包 (转载)

    转自:http://blog.csdn.net/zhou_2008/article/details/6076900 在debian下,你可以使用dpkg(Debian package system)来 ...

  5. inno安装卸载时检测程序是否正在运行卸载完成后自动打开网页-代码无效

    inno安装卸载时检测程序是否正在运行卸载完成后自动打开网页-代码无效 inno setup 安装卸载时检测程序是佛正在运行卸载完成后自动打开网页-代码无效 --------------------- ...

  6. Windows Service的安装卸载 和 Service控制(转)

    Windows Service的安装卸载 和 Service控制 原文地址:http://www.cnblogs.com/Peter-Zhang/archive/2011/10/15/2212663. ...

  7. 15个Linux Yum命令实例--安装/卸载/更新

    在linux环境中, 安装, 卸载更新包是一个极为常见的操作.大部分的linux环境都提供了包的管理工具, 例如:apt-get, dpkg, rpm, yum等等. 一些Linux环境中,yum是默 ...

  8. Delphi安装/卸载OCX控件的方法

    delphi  安装卸载ocx 请参见 如下 http://blog.csdn.net/xt_chaoji/article/details/7027298 打开Delphi,关闭所有项目. 1.    ...

  9. WPF 自己动手来做安装卸载程序

    原文:WPF 自己动手来做安装卸载程序 前言 说起安装程序,这也许是大家比较遗忘的部分,那么做C/S是小伙伴们,难道你们的程序真的不需要一个炫酷的安装程序么? 声明在先 本文旨在教大家以自己的方式实现 ...

随机推荐

  1. Linux系统的命令源码的获取方法

    我们知道,Linux是开源的,它自带的功能强大的命令也是开源的,也就是说.我们能够获得这些命令的源码并研究它.那到底怎样获得系统的命令的源码呢? 命令的源码是一个软件包为单元的,放在一个软件包的源码中 ...

  2. Xmind8破解激活

    1.下载安装包: https://www.xmind.cn/download/ 进行安装 2.下载破解补丁: https://stormxing.oss-cn-beijing.aliyuncs.com ...

  3. hdoj---Rescue

    Rescue Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other) Total Submis ...

  4. 2.2.3 修改JSX代码

    /** * Sample React Native App * https://github.com/facebook/react-native * @flow */ import React, { ...

  5. 函数和指针 C++

    一.用函数指针变量调用函数. 指针变量也可以指向一个函数,一个函数在编译时被分配给一个入口地址.这个函数入口地址就称为函数的指针.可以用一个指针变量指向函数,然后通过该指针变量调用此函数. 定义指向函 ...

  6. WPF中ListBox ListView数据翻页浏览笔记(强调:是数据翻页,非翻页动画)

    ListBox和ListView在应用中,常常有需求关于每页显示固定数量的数据,然后通过Timer自动或者手动翻页操作,本文介绍到的就是该动作的实现. 一.重点 对于ListBox和ListView来 ...

  7. vim下的autocmd

    AUTOCMD *autocmd.txt* For Vim version 6.2. 最后修改: 2003年3月28日 VIM 参考手册 作者:Bram Moolenaar 翻译:Zimin<c ...

  8. Queue 与List、LinkedList与 ArrayList 区别

    List 是一个接口,不能实例化,通过实例化ArrayList 或者LinkedList来调用:List list = new ArrayList(); |--List: 元素是有序的(怎么存的就怎么 ...

  9. 全面改造升级内部OA系统

    项目功能集团的OA办公系统,分别是销售管理系统.财务付款系统.原料采购系统.成品采购系统.担保系统和库房管理系统业务现状成品采购系统.库房管理系统.销售管理系统是Access开发的C/S系统,采用本地 ...

  10. Windows Server2008上安装VS2008出错及解决办法

    作者:朱金灿 来源:http://blog.csdn.net/clever101 win server 2008安装vs2008后报错,如下图: 然后到网上找了一种解决办法: (1)打开服务器管理器 ...