对于想了解Linux卸载mysql的读者,本文将是一篇不可错过的文章,我们将详细介绍linux卸载MySQL数据库,并且为您提供关于linux-mysql-卸载:RPM包安装方式的MySQL卸载、Li
对于想了解Linux 卸载mysql的读者,本文将是一篇不可错过的文章,我们将详细介绍linux卸载MySQL数据库,并且为您提供关于linux - mysql - 卸载:RPM包安装方式的MySQL卸载、Linux 6.7卸载MySQL8.0.16、Linux CentOS 7 卸载mariadb 安装mysql5.5、linux Debian完全卸载mysql 再安装的有价值信息。
本文目录一览:- Linux 卸载mysql(linux卸载MySQL数据库)
- linux - mysql - 卸载:RPM包安装方式的MySQL卸载
- Linux 6.7卸载MySQL8.0.16
- Linux CentOS 7 卸载mariadb 安装mysql5.5
- linux Debian完全卸载mysql 再安装
Linux 卸载mysql(linux卸载MySQL数据库)
Linux 卸载MysqL
系统环境:CentOS 6.8。
MysqL的安装主要有三种方式:二进制包安装(Using Generic Binaries)、RPM包安装、源码安装。
所以卸载方式也可能不一样。
我测试的是源码安装的。
(1)卸载前关闭MysqL服务
1、查看MysqL服务状态:
service MysqL status
2、停止MysqL服务:
service MysqL stop
(2)查看MysqL组件信息:
执行命令:rpm -qa | grep -i MysqL
如果有组件信息,使用命令卸载组件: rpm -ev 组件名字。
(3)收集MysqL对应的文件夹信息
执行命令:whereis MysqL
结果示例:MysqL: /usr/lib64/MysqL /usr/local/MysqL /usr/share/MysqL
执行命令:find / -name MysqL
结果示例:
/var/spool/mail/MysqL
/var/MysqL
/var/MysqL/data/MysqL
/var/lib/MysqL
/lnmp/src/MysqL-5.5.62-linux-glibc2.12-x86_64/include/MysqL
/lnmp/src/MysqL-5.5.62-linux-glibc2.12-x86_64/bin/MysqL
/lnmp/src/MysqL-5.5.62/include/MysqL
/lnmp/src/MysqL-5.5.62/client/MysqL
/home/MysqL
/data/MysqL
/usr/share/MysqL
/usr/lib64/MysqL
/usr/local/MysqL
/usr/local/MysqL/include/MysqL
/usr/local/MysqL/bin/MysqL
执行命令删除上边展示的所有文件夹:
rm -rf 两个命令显示列表中的文件夹。
(4)删除配置文件:
rm -rf /etc/my.cnf
rm -rf /etc/init.d/MysqLd
(5)删除msyql用户:
执行命令:more /etc/passwd | grep MysqL
MysqL:x:101:501::/home/MysqL:/bin/bash
执行命令:more /etc/shadow | grep MysqL
示例结果:MysqL:!!:16496::::::
执行命令:more /etc/group | grep MysqL
示例结果:MysqL:x:501:
执行删除用户命令:userdel MysqL
执行删除用户组命令:groupdel MysqL
或者使用命令:id MysqL也可以查看msyql用户。
(6)确认MysqL是否卸载删除
rpm -qa | grep -i MysqL
(7)二进制包/源码安装方式的MysqL卸载
如果是采用二进制包安装的MysqL,那么你用下面命令是找不到任何MysqL组件的。所以如果你不知道MysqL的安装方式,千万不要用下面命令来判别是否安装了MysqL
rpm -qa | grep -i MysqL。
linux - mysql - 卸载:RPM包安装方式的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
(2)卸载前关闭MySQL服务
[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]
(3)收集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]# 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
备注:
问题现象:如果在卸载的过程中,无法卸载,并报错:error: Failed dependencies:
mysql = 5.1.73-5.el6_6 is needed by (installed) mysql-server-5.1.73-5.el6_6.x86_64
原因:有依赖包
解决办法:加参数--nodeps
例如原来删除命令:rpm -ev MySQL-client-5.6.23-1.linux_glibc2.5
修改后删除命令:rpm -ev MySQL-client-5.6.23-1.linux_glibc2.5 --nodeps
(5)删除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
(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
Linux 6.7卸载MySQL8.0.16
[root@node01 vsftpd]# uname -r
2.6.32-754.10.1.el6.x86_64
[root@node01 vsftpd]# rpm -qa|grep -i mysql
mysql-community-libs-8.0.16-1.el6.x86_64
mysql80-community-release-el6-3.noarch
mysql-community-devel-8.0.16-1.el6.x86_64
mysql-community-common-8.0.16-1.el6.x86_64
mysql-community-test-8.0.16-1.el6.x86_64
mysql-community-server-8.0.16-1.el6.x86_64
mysql-community-client-8.0.16-1.el6.x86_64
[root@node01 vsftpd]# service mysqld status
mysqld (pid 40238) is running...
[root@node01 vsftpd]# service mysqld stop
Stopping mysqld: [ OK ]
[root@node01 vsftpd]# service mysqld status
mysqld is stopped
[root@node01 vsftpd]# rpm -e --nodeps mysql-community-libs-8.0.16-1.el6.x86_64
[root@node01 vsftpd]# rpm -e --nodeps mysql80-community-release-el6-3.noarch
[root@node01 vsftpd]# rpm -e --nodeps mysql-community-devel-8.0.16-1.el6.x86_64
[root@node01 vsftpd]# rpm -e --nodeps mysql-community-common-8.0.16-1.el6.x86_64
[root@node01 vsftpd]# rpm -e --nodeps mysql-community-test-8.0.16-1.el6.x86_64
[root@node01 vsftpd]# rpm -e --nodeps mysql-community-server-8.0.16-1.el6.x86_64
[root@node01 vsftpd]# rpm -e --nodeps mysql-community-client-8.0.16-1.el6.x86_64
[root@node01 vsftpd]# rpm -qa|grep -i mysql
[root@node01 vsftpd]# find / -name mysql
/opt/********/data/mysql
/var/spool/mail/mysql
/var/swstore/mysql
/var/lib/mysql
/var/lib/mysql/mysql
/usr/lib64/mysql
[root@node01 vsftpd]# rm -rf /opt/********/data/mysql
[root@node01 vsftpd]# rm -rf /var/spool/mail/mysql
[root@node01 vsftpd]# rm -rf /var/swstore/mysql
[root@node01 vsftpd]# rm -rf /var/lib/mysql
[root@node01 vsftpd]# rm -rf /var/lib/mysql/mysql
[root@node01 vsftpd]# rm -rf /usr/lib64/mysql
[root@node01 vsftpd]# rm -rf /etc/my.cnf
[root@node01 vsftpd]# find / -name mysql
[root@node01 vsftpd]#
Linux CentOS 7 卸载mariadb 安装mysql5.5
以前的Linux系统中数据库大部分是mysql,不过自从被sun收购之后,就没用集成在centos这些开源Linux系统中了,那么如果想用的话就需要自己安装了,首先centos7 已经不支持mysql,因为收费了你懂得,所以内部集成了mariadb,而安装mysql的话会和mariadb的文件冲突,所以需要先卸载掉mariadb,以下为卸载mariadb,安装mysql的步骤。
#列出所有被安装的rpm package
1
|
rpm -qa | grep mariadb
|
#卸载
1
|
rpm -e mariadb-libs-5.5.37-1.el7_0.x86_64
|
错误:依赖检测失败:
libmysqlclient.so.18()(64bit) 被 (已安裝) postfix-2:2.10.1-6.el7.x86_64 需要
libmysqlclient.so.18(libmysqlclient_18)(64bit) 被 (已安裝) postfix-2:2.10.1-6.el7.x86_64 需要
#强制卸载,因为没有--nodeps
rpm -e --nodeps mariadb-libs-5.5.37-1.el7_0.x86_64
#安装mysql5.5.39的rpm包
rpm -ivh /home/liwei/MySQL-server-5.5.39-2.el6.x86_64.rpm
rpm -ivh /home/liwei/MySQL-client-5.5.39-2.el6.x86_64.rpm
#拷贝配置文件
cp /usr/share/mysql/my-medium.cnf /etc/my.cnf,改名为my.cnf作为mysql配置文件。
#修改响应的配置文件
vim /etc/my.cnf
#把mysql的data拷贝到制定的目录
mv /var/lib/mysql /home/mysql/data/
还要注意目录的属主和权限。
MYSQL启动后报:ERROR! The server quit without updating PID file错误的问题解决
1、权限不够:chown -R mysql:mysql /home/mysql/data” “chmod -R 755 /home/mysql/data
2、centos7的selinux问题:打开/etc/selinux/config,把SELINUX=enforcing改为SELINUX
centos7 安装 mariadb 的正确命令
使用的是linode的centos7系统,安装mysql发现已经默认的是mariadb。
但是不管是使用linode官网说明还是百度搜索到的的根本安装方法无法安装成功。
总是提示这一句:
ERROR 2002 (HY000): Can''t connect to local Mysql server through socket ''/var/lib/mysql/mysql.sock'' (2)
最后通过google 搜索 install mariadb on centos 7得到了安装的关键一步。
现在安装成功,特此备注一下整个安装过程:
mysql:[root@localhost ~]# yum -y install mariadb*
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.linode.com
* extras: mirrors.linode.com
* updates: mirrors.linode.com
Resolving Dependencies
--> Running transaction check
---> Package mariadb.x86_64 1:5.5.37-1.el7_0 will be installed
---> Package mariadb-bench.x86_64 1:5.5.37-1.el7_0 will be installed
---> Package mariadb-devel.x86_64 1:5.5.37-1.el7_0 will be installed
---> Package mariadb-embedded.x86_64 1:5.5.37-1.el7_0 will be installed
---> Package mariadb-embedded-devel.x86_64 1:5.5.37-1.el7_0 will be installed
---> Package mariadb-libs.x86_64 1:5.5.37-1.el7_0 will be installed
---> Package mariadb-server.x86_64 1:5.5.37-1.el7_0 will be installed
--> Processing Dependency: perl-DBD-MySQL for package: 1:mariadb-server-5.5.37-1.el7_0.x86_64
---> Package mariadb-test.x86_64 1:5.5.37-1.el7_0 will be installed
--> Running transaction check
---> Package perl-DBD-MySQL.x86_64 0:4.023-5.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
==========================================================================================================
Package Arch Version Repository Size
==========================================================================================================
Installing:
mariadb x86_64 1:5.5.37-1.el7_0 updates 8.9 M
mariadb-bench x86_64 1:5.5.37-1.el7_0 updates 385 k
mariadb-devel x86_64 1:5.5.37-1.el7_0 updates 744 k
mariadb-embedded x86_64 1:5.5.37-1.el7_0 updates 3.6 M
mariadb-embedded-devel x86_64 1:5.5.37-1.el7_0 updates 7.4 M
mariadb-libs x86_64 1:5.5.37-1.el7_0 updates 752 k
mariadb-server x86_64 1:5.5.37-1.el7_0 updates 11 M
mariadb-test x86_64 1:5.5.37-1.el7_0 updates 7.9 M
Installing for dependencies:
perl-DBD-MySQL x86_64 4.023-5.el7 base 140 k
Transaction Summary
==========================================================================================================
Install 8 Packages (+1 Dependent package)
Total download size: 40 M
Installed size: 279 M
Downloading packages:
(1/9): mariadb-bench-5.5.37-1.el7_0.x86_64.rpm | 385 kB 00:00:00
(2/9): mariadb-devel-5.5.37-1.el7_0.x86_64.rpm | 744 kB 00:00:00
(3/9): mariadb-embedded-5.5.37-1.el7_0.x86_64.rpm | 3.6 MB 00:00:00
(4/9): mariadb-5.5.37-1.el7_0.x86_64.rpm | 8.9 MB 00:00:00
(5/9): mariadb-libs-5.5.37-1.el7_0.x86_64.rpm | 752 kB 00:00:00
(6/9): mariadb-server-5.5.37-1.el7_0.x86_64.rpm | 11 MB 00:00:00
(7/9): mariadb-embedded-devel-5.5.37-1.el7_0.x86_64.rpm | 7.4 MB 00:00:00
(8/9): mariadb-test-5.5.37-1.el7_0.x86_64.rpm | 7.9 MB 00:00:00
(9/9): perl-DBD-MySQL-4.023-5.el7.x86_64.rpm | 140 kB 00:00:00
----------------------------------------------------------------------------------------------------------
Total 36 MB/s | 40 MB 00:00:01
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : 1:mariadb-libs-5.5.37-1.el7_0.x86_64 1/9
Installing : 1:mariadb-5.5.37-1.el7_0.x86_64 2/9
Installing : perl-DBD-MySQL-4.023-5.el7.x86_64 3/9
Installing : 1:mariadb-server-5.5.37-1.el7_0.x86_64 4/9
Installing : 1:mariadb-devel-5.5.37-1.el7_0.x86_64 5/9
Installing : 1:mariadb-embedded-5.5.37-1.el7_0.x86_64 6/9
Installing : 1:mariadb-embedded-devel-5.5.37-1.el7_0.x86_64 7/9
Installing : 1:mariadb-test-5.5.37-1.el7_0.x86_64 8/9
Installing : 1:mariadb-bench-5.5.37-1.el7_0.x86_64 9/9
Verifying : 1:mariadb-test-5.5.37-1.el7_0.x86_64 1/9
Verifying : 1:mariadb-embedded-devel-5.5.37-1.el7_0.x86_64 2/9
Verifying : 1:mariadb-embedded-5.5.37-1.el7_0.x86_64 3/9
Verifying : 1:mariadb-libs-5.5.37-1.el7_0.x86_64 4/9
Verifying : 1:mariadb-bench-5.5.37-1.el7_0.x86_64 5/9
Verifying : 1:mariadb-5.5.37-1.el7_0.x86_64 6/9
Verifying : 1:mariadb-server-5.5.37-1.el7_0.x86_64 7/9
Verifying : perl-DBD-MySQL-4.023-5.el7.x86_64 8/9
Verifying : 1:mariadb-devel-5.5.37-1.el7_0.x86_64 9/9
Installed:
mariadb.x86_64 1:5.5.37-1.el7_0 mariadb-bench.x86_64 1:5.5.37-1.el7_0
mariadb-devel.x86_64 1:5.5.37-1.el7_0 mariadb-embedded.x86_64 1:5.5.37-1.el7_0
mariadb-embedded-devel.x86_64 1:5.5.37-1.el7_0 mariadb-libs.x86_64 1:5.5.37-1.el7_0
mariadb-server.x86_64 1:5.5.37-1.el7_0 mariadb-test.x86_64 1:5.5.37-1.el7_0
Dependency Installed:
perl-DBD-MySQL.x86_64 0:4.023-5.el7
Complete!
[root@localhost ~]# systemctl start mariadb.service
[root@localhost ~]# systemctl enable mariadb.service
ln -s ''/usr/lib/systemd/system/mariadb.service'' ''/etc/systemd/system/multi-user.target.wants/mariadb.servi
ce''
[root@localhost ~]# mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.37-MariaDB MariaDB Server
Copyright (c) 2000, 2014, Oracle, Monty Program Ab and others.
Type ''help;'' or ''\h'' for help. Type ''\c'' to clear the current input statement.
MariaDB [(none)]> logout
-> exit
->
-> ;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaD
B server version for the right syntax to use near ''logout
exit'' at line 1
MariaDB [(none)]> exit
Bye
[root@localhost ~]# systemctl enable mariadb.service
[root@localhost ~]# mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 5.5.37-MariaDB MariaDB Server
Copyright (c) 2000, 2014, Oracle, Monty Program Ab and others.
Type ''help;'' or ''\h'' for help. Type ''\c'' to clear the current input statement.
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.00 sec)
MariaDB [(none)]> use test
Database changed
MariaDB [test]> show tables;
Empty set (0.00 sec)
MariaDB [test]> exit
Bye
[root@localhost ~]# mysql_secure_installation
/usr/bin/mysql_secure_installation: line 379: find_mysql_client: command not found
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we''ll need the current
password for the root user. If you''ve just installed MariaDB, and
you haven''t set the root password yet, the password will be blank,
so you should just press enter here.
ERROR 1045 (28000): Access denied for user ''root''@''localhost'' (using password: YES)
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!
By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] y
... Success!
Normally, root should only be allowed to connect from ''localhost''. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] y
... Success!
By default, MariaDB comes with a database named ''test'' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] y
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] y
... Success!
Cleaning up...
All done! If you''ve completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!
[root@localhost ~]# mysql -uroot -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 15
Server version: 5.5.37-MariaDB MariaDB Server
Copyright (c) 2000, 2014, Oracle, Monty Program Ab and others.
Type ''help;'' or ''\h'' for help. Type ''\c'' to clear the current input statement.
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| zbphp.com |
+--------------------+
4 rows in set (0.00 sec)
MariaDB [(none)]>
MariaDB相关命令:
systemctl start mariadb #启动MariaDB
systemctl stop mariadb #停止MariaDB
systemctl restart mariadb #重启MariaDB
systemctl enable mariadb #设置开机启动
systemctl status mariadb #查看MariaDB状态
linux Debian完全卸载mysql 再安装
前情提要: 由于操作失误,导致无法启动mysql。于是只能卸载mysql重新安装。但是由于没有卸载干净,导致无法安装上新的 mysql
博主刚开始使用的方法:
sudo apt-get --purge remove mysql-server sudo apt-get install mysql-server
最终宣告失败;
罗列所有mysql相关软件
通过dpkg --get-selections | grep mysql
命令罗列出你电脑上安装的和MySQL相关的软件,然后purge卸载。
sudo apt-get --purge remove mysql-server sudo apt-get --purge remove mysql-client sudo apt-get --purge remove mysql-common 卸载后,再次查看 |
发现并没有卸载干净 再用sudo apt-get --purge remove mysql-core-server-5.5
卸载残留
apt-get autoremove apt-get autoclean |
到这里就已经卸载好了。重新安装即可。sudo apt-get install mysql-server
如果需要远程连接数据库 请参考上篇博文。https://my.oschina.net/u/3022975/blog/1531703
关于Linux 卸载mysql和linux卸载MySQL数据库的问题我们已经讲解完毕,感谢您的阅读,如果还想了解更多关于linux - mysql - 卸载:RPM包安装方式的MySQL卸载、Linux 6.7卸载MySQL8.0.16、Linux CentOS 7 卸载mariadb 安装mysql5.5、linux Debian完全卸载mysql 再安装等相关内容,可以在本站寻找。
本文标签: