1. 程式人生 > >黑猴子的家:解除安裝Linux系統自帶MySql資料庫

黑猴子的家:解除安裝Linux系統自帶MySql資料庫

1、關閉mysql服務

[[email protected] ~]# systemctl status mysql
[[email protected] ~]# systemctl stop mysql
尖叫提示:解除安裝用root使用者

2、檢視

[[email protected] ~]# rpm -qa | grep -i mysql
[[email protected] ~]# rpm -qa | grep -i mariadb

3、解除安裝全部查詢出來的

[[email protected] ~]# yum -y remove mysql-* …….. 
[[email protected] ~]# yum -y remove MySQL-client-5.7.21-1.el7.x86_64 [[email protected] ~]# yum -y remove MySQL-server-5.7.21-1.el7.x86_64 [[email protected] ~]# rpm -e --nodeps mariadb-libs-5.5.41-2.el7_0.x86_64 [[email protected] ~]# rpm -e --nodeps mysql-libs-5.1.73-7.el6.x86_64 ……….
尖叫提示:解除安裝的時候儘量別用“*”號,使用全稱。

4、刪除分散mysql資料夾,刪除查詢出來的

[[email protected] ~]# whereis mysql
[[email protected] ~]# rm -rf /usr/lib/mysql/  
[[email protected] ~]# rm -rf /usr/share/mysql  
[[email protected] ~]# rm -rf /etc/my.cnf
[[email protected] ~]# rm -rf /var/lib/mysql
[[email protected]
~]# rm -rf /root/.mysql_sercret ……. 尖叫提示:rm -rf /var/lib/mysql(如果這個目錄如果不刪除,再重新安裝之後, 密碼還是之前的密碼,不會重新初始化!) [[email protected] ~]# find / -name mysql* [[email protected] ~]# rm -rf ****

5、檢查一下是否刪除乾淨

[[email protected] ~]# rpm -qa | grep -i mysql
[[email protected] ~]# rpm -qa | grep -i mariadb
[[email protected] ~]# whereis mysql
[[email protected] ~]# find / -name mysql*

6、確定是不是真的解除安裝乾淨

(1)是看安裝輸出 如果沒有解除安裝乾淨,安裝server時輸入只有兩行

[[email protected] MySQL-5.7.21-rpm]# rpm -ivh MySQL-server-5.7.21-1.el7.x86_64.rpm 
Preparing...   ################################# [100%]
Updating / installing... MySQL-server-5.7.21-1.el7################################# [100%]

解除安裝乾淨了安裝輸入如下

[[email protected] MySQL-5.7.21-rpm]# rpm -ivh MySQL-server-5.7.21-1.el7.x86_64.rpm 
Preparing...   ################################# [100%]
Updating / installing...MySQL-server-5.7.21-1.el7################################# [100%]
2018-03-16 15:14:49 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-03-16 15:14:49 0 [Note] /usr/sbin/mysqld (mysqld 5.7.21) starting as process 5826 ...
2018-03-16 15:14:49 5826 [Note] InnoDB: Using atomics to ref count buffer pool pages
2018-03-16 15:14:49 5826 [Note] InnoDB: The InnoDB memory heap is disabled
2018-03-16 15:14:49 5826 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2018-03-16 15:14:49 5826 [Note] InnoDB: Memory barrier is not used
2018-03-16 15:14:49 5826 [Note] InnoDB: Compressed tables use zlib 1.2.3
2018-03-16 15:14:49 5826 [Note] InnoDB: Using Linux native AIO
2018-03-16 15:14:49 5826 [Note] InnoDB: Using CPU crc32 instructions
2018-03-16 15:14:49 5826 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2018-03-16 15:14:49 5826 [Note] InnoDB: Completed initialization of buffer pool
2018-03-16 15:14:49 5826 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2018-03-16 15:14:49 5826 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2018-03-16 15:14:49 5826 [Note] InnoDB: Database physically writes the file full: wait...
2018-03-16 15:14:49 5826 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2018-03-16 15:14:49 5826 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2018-03-16 15:14:50 5826 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2018-03-16 15:14:50 5826 [Warning] InnoDB: New log files created, LSN=45781
2018-03-16 15:14:50 5826 [Note] InnoDB: Doublewrite buffer not found: creating new
2018-03-16 15:14:50 5826 [Note] InnoDB: Doublewrite buffer created
2018-03-16 15:14:50 5826 [Note] InnoDB: 128 rollback segment(s) are active.
2018-03-16 15:14:50 5826 [Warning] InnoDB: Creating foreign key constraint system tables.
2018-03-16 15:14:50 5826 [Note] InnoDB: Foreign key constraint system tables created
2018-03-16 15:14:50 5826 [Note] InnoDB: Creating tablespace and datafile system tables.
2018-03-16 15:14:50 5826 [Note] InnoDB: Tablespace and datafile system tables created.
2018-03-16 15:14:50 5826 [Note] InnoDB: Waiting for purge to start
2018-03-16 15:14:50 5826 [Note] InnoDB: 5.7.21 started; log sequence number 0
A random root password has been set. You will find it in '/root/.mysql_secret'.
2018-03-16 15:14:50 5826 [Note] Binlog end
2018-03-16 15:14:50 5826 [Note] InnoDB: FTS optimize thread exiting.
2018-03-16 15:14:50 5826 [Note] InnoDB: Starting shutdown...
2018-03-16 15:14:52 5826 [Note] InnoDB: Shutdown completed; log sequence number 1625977
2018-03-16 15:14:52 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-03-16 15:14:52 0 [Note] /usr/sbin/mysqld (mysqld 5.7.21) starting as process 5848 ...
2018-03-16 15:14:52 5848 [Note] InnoDB: Using atomics to ref count buffer pool pages
2018-03-16 15:14:52 5848 [Note] InnoDB: The InnoDB memory heap is disabled
2018-03-16 15:14:52 5848 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2018-03-16 15:14:52 5848 [Note] InnoDB: Memory barrier is not used
2018-03-16 15:14:52 5848 [Note] InnoDB: Compressed tables use zlib 1.2.3
2018-03-16 15:14:52 5848 [Note] InnoDB: Using Linux native AIO
2018-03-16 15:14:52 5848 [Note] InnoDB: Using CPU crc32 instructions
2018-03-16 15:14:52 5848 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2018-03-16 15:14:52 5848 [Note] InnoDB: Completed initialization of buffer pool
2018-03-16 15:14:52 5848 [Note] InnoDB: Highest supported file format is Barracuda.
2018-03-16 15:14:52 5848 [Note] InnoDB: 128 rollback segment(s) are active.
2018-03-16 15:14:52 5848 [Note] InnoDB: Waiting for purge to start
2018-03-16 15:14:52 5848 [Note] InnoDB: 5.7.21 started; log sequence number 1625977
2018-03-16 15:14:52 5848 [Note] Binlog end
2018-03-16 15:14:52 5848 [Note] InnoDB: FTS optimize thread exiting.
2018-03-16 15:14:52 5848 [Note] InnoDB: Starting shutdown...
2018-03-16 15:14:54 5848 [Note] InnoDB: Shutdown completed; log sequence number 1625987
A RANDOM PASSWORD HAS BEEN SET FOR THE MySQL root USER !
You will find that password in '/root/.mysql_secret'.
You must change that password on your first connect,
no other statement but 'SET PASSWORD' will be accepted.
See the manual for the semantics of the 'password expired' flag.
Also, the account for the anonymous user has been removed.
In addition, you can run:
/usr/bin/mysql_secure_installation
which will also give you the option of removing the test database.
This is strongly recommended for production servers.
See the manual for more instructions.
Please report any problems at http://bugs.mysql.com/
The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at http://shop.mysql.com
New default config file was created as /usr/my.cnf and
will be used by default by the server when you start it.
You may edit this file to change server settings
最後一段中提示了重要資訊。 

(2)就是安裝完成,啟動服務之後

使用命令:”mysql -uroot –p”輸入你之前安裝後設置的密碼,看能不能登入,如果還可以登入,說明沒有解除安裝乾淨!