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. Codeforces Round #253 (Div. 1)-A,B

    A题: 由题意可知,最多翻10次就能够(事实上8次就够了).那么我们就用状态压缩表示状态. 对于某种状态,假设某一位为0,那么代表这一位不翻,否则代表这一位翻. 对于某一种翻的状态: 假设牌中有G3, ...

  2. 消息推送之百度云推送Android集成与用法

    这两天因为项目须要.研究了一下百度云推送,本来这事没什么多大工作量的,但注冊百度开发人员账户创建应用令我蛋疼菊紧了好一阵,这些东西做了对技术没啥提升,不做又不行,必经之路. 好在我耗费了N多个毫毫秒秒 ...

  3. element-UI中table表格的row-click事件怎么获取一行数据的id

    <el-table :data="tableData" style="width: 100%" @row-click="openDetails( ...

  4. Android——build.prop 解析【转】

    本文转载自:http://blog.csdn.net/lengyue1084/article/details/77637354 一.概念 在Android设备shell终端可以看到/system目录下 ...

  5. [HTML5] 让IE支持HTML5的方法

    越来越多的站点开始使用 HTML5 标签,但是目前的情况是还有很多人在使用IE6.IE7.IE8.为了让所有浏览者都可以正常的访问,解决方案有下面两个: 1.为网站创建多套模板,通过程序对User-A ...

  6. cas-client-core单点登录排除不需要拦截的URL

    同事提了一个要求,要求对外提供的接口不需要经过单点登录验证,我刚开始想,这简单,提供不需要拦截的url数组,在AuthenticationFilter里面对url进行检查,在此数组内,就不需要拦截. ...

  7. getElementById和querySelector区别

    1.常见的获取元素的方法有3种,分别是通过元素ID document.getElementById('idName');.通过标签名字document.getElementsByTagName(tag ...

  8. [Codeforces]Educational Codeforces Round 37 (Rated for Div. 2)

    Water The Garden #pragma comment(linker, "/STACK:102400000,102400000") #include<stdio.h ...

  9. 给WordPress的TinyMCE Advanced编辑器加上中文字体

    为TinyMCE编辑器增加中文字体并不复杂,只需要将将如下代码加到当前主题的functions.php文件中最后一个?>的前面即可: 不要忘记保存,然后更新一遍浏览器即可 //为TinyMCE编 ...

  10. android黑科技系列——静态分析技术来破解Apk

    一.前言 从这篇文章开始我们开始我们的破解之路,之前的几篇文章中我们是如何讲解怎么加固我们的Apk,防止被别人破解,那么现在我们要开始破解我们的Apk,针对于之前的加密方式采用相对应的破解技术,And ...