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. 时序图与状态图(Rose) - Windows XP经典软件系列

    以CAN转UART(串口)为例. 功能简单介绍: 当主程序收到CAN口的数据后:依据按键的不同来选择是使用CAN口发送,还是使用UART口发送. 一.图片 时序图 watermark/2/text/a ...

  2. 2015年趋势科技笔试A卷

    题目原题来源:url=BHz9dr7Dbql5Ai0fTaUsi8QH-ieA9UAtw8kpf-Us_cGUnsz7ZIU1SfHIp33Cphcp0n6uPikWL6r8n0a0zQ0wNOMLG ...

  3. poj1753,Flip Game,ArrayDeque&lt;Node&gt;

    Flip Game Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 30449   Accepted: 13232 Descr ...

  4. java,wavToMP3格式转换

    这里须要用到一个jar包:jave-1.0.1.jar,下载地址的话自己百度吧. 废话不多说直接贴代码: import it.sauronsoftware.jave.AudioAttributes; ...

  5. Online Object Tracking: A Benchmark 论文笔记

    Factors that affect the performance of a tracing algorithm 1 Illumination variation 2 Occlusion 3 Ba ...

  6. 【JavaScript】在同一个网页中实现多个JavaScript特效

    在网页中,假设出现两次<script type="text/javascript"></script>标签,全部的JavaScipt脚本都不会再生效,仅仅能 ...

  7. nginx源代码分析--进程间通信机制 &amp; 同步机制

    Nginx源代码分析-进程间通信机制 从nginx的进程模型能够知道.master进程和worker进程须要通信,nginx中通信的方式有套接字.共享内存.信号.对于master进程,从外部接受信号, ...

  8. 安装visual studio 2013--【转】

    本文转载自:http://blog.csdn.net/tina_ttl/article/details/51544733#1下载-visual-studio-ultimate-2013安装包 1.下载 ...

  9. 0x58B 四边形不等式

    bzoj1563: [NOI2009]诗人小G 还有优化二维区间DP的,形如f[i][j]min{f[i][k]+f[k][j+1]+val(i,j)} 其中val满足四边形不等式,而且对于任意a&l ...

  10. python 读取二进制文件 转为16进制输出

    示例: #!/usr/bin/env python #encoding: utf-8 import binascii fh = open(r'C:\Temp\img\2012517165556.png ...