mysql学习心得之linux卸载mysql与rpm包安装(3)

时间:2022-12-25 17:10:00

今天安装了一个oracle linux6.4的虚拟机,默认竟然安装了mysql,本想开始学习怎么在linux下安装mysql的,现在只好先学习怎么卸载吧。

首先查找安装的mysql的rpm包。

[root@mysql /]# rpm -qa|grep -i mysql
mysql-devel-5.1.71-1.el6.x86_64
perl-DBD-MySQL-4.013-3.el6.x86_64
qt-mysql-4.6.2-26.el6_4.x86_64
mysql-libs-5.1.71-1.el6.x86_64
mysql-server-5.1.71-1.el6.x86_64
mysql-5.1.71-1.el6.x86_64
为了不带上linux包的依赖校验,我们需要用如下的命令卸载上面的包。

[root@mysql /]# rpm -ev --allmatches --nodeps  mysql-devel-5.1.71-1.el6.x86_64
[root@mysql /]# rpm -ev --allmatches --nodeps mysql-server-5.1.71-1.el6.x86_64
[root@mysql /]# rpm -ev --allmatches --nodeps mysql-5.1.71-1.el6.x86_64
[root@mysql /]# rpm -ev --allmatches --nodeps mysql-libs-5.1.71-1.el6.x86_64
[root@mysql /]# rpm -ev --allmatches --nodeps qt-mysql-4.6.2-26.el6_4.x86_64
[root@mysql /]# rpm -ev --allmatches --nodeps perl-DBD-MySQL-4.013-3.el6.x86_64

下面就是把我们的mysql的rpm包传到linux上去,在mysql5,.1的中文官方文档里面说了这样一句话“在大多数情况,你只需要安装MySQL-serverMySQL-client软件包来安装MySQL”。所以我们这里就只安装这两个包。

[root@mysql Csong]# rpm -ivh MySQL-client-5.5.47-1.el6.x86_64.rpm 
warning: MySQL-client-5.5.47-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ########################################### [100%]
1:MySQL-client ########################################### [100%]
[root@mysql Csong]# rpm -ivh MySQL-server-5.5.47-1.el6.x86_64.rpm
warning: MySQL-server-5.5.47-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ########################################### [100%]
1:MySQL-server ########################################### [100%]
151231 16:11:54 [Note] /usr/sbin/mysqld (mysqld 5.5.47) starting as process 5079 ...
151231 16:11:54 [Note] /usr/sbin/mysqld (mysqld 5.5.47) starting as process 5086 ...

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h mysql password 'new-password'

Alternatively you can run:
/usr/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.

See the manual for more instructions.

Please report any problems at http://bugs.mysql.com/
[root@mysql Csong]# mysqlERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)[root@mysql Csong]# service mysql startStarting MySQL..                                           [  OK  ][root@mysql Csong]# mysqladmin -u root password 123456[root@mysql Csong]# mysql -uroot -p123456Welcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 3Server version: 5.5.47 MySQL Community Server (GPL)Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> 
至此简单的用rpm包来安装mysql就完成了。