Linux(Fedora 9)卸载自带的MySQL并安装MySQL的详细步骤

Linux(Fedora 9)卸载自带的MySQL并安装MySQL的详细步骤

 

       又折腾了一个下午,终于把MySQL装上去了,T_T|||。在Linux装个软件都要这么的麻烦来着,在Windows下双击就可以解决一切问题。

       Linux程序设计(第3版)》稍微提了一点MySQL的安装,但这完全是不够用的。在网上查博客,出乎我意料的是,居然很少有文章是描述这一问题的。在安装的过程中有些人遇到的问题是和我一样的,但很少有人针对此问题给出比较明确的回答或者是比较完备详细的安装过程,有可能是我没有搜索到——|||

参考了几篇博客描述的方法及自己的亲身实践,大概总结出了安装MySQL过程中几个常见的问题和相关的解决方案。

注意:以下的步骤并不是实际真正需要安装的步骤,而是为了寻求问题解决方法而进行操作的步骤,在此会发现并解决一些问题:

 

   (1)《Linux程序设计(第3版)》写着的:MySQL被分解成了很多个不同的RPM软件包,如果不使用Linux系统自带的MySQL,需要下载MySQL四个比较重要的RPM包,分别是:主服务包(mian server package)、客户端包(client package)、共享组件包(shared component package)和开发包(development package)。麻烦吧,装个软件还要搞这么多个包,其实我只装了前两个,后两个没装。下载地址:http://www.mysql.com/downloads/mysql/#downloads。现在我所使用的版本为:MySQL Community Server 5.1.46

 

   (2)下载完几个RPM包后,先装主服务包MySQL-server-community-5.1.46-1.rhel4.i386.rpm

 [root@localhost install]# rpm -ivh MySQL-server-community-5.1.46-1.rhel4.i386.rpm Preparing... ########################################### [100%] file /etc/my.cnf from install of MySQL-server-community-5.1.46-1.rhel4.i386 conflicts with file from package mysql-libs-5.0.51a-1.fc9.i386 file /usr/share/mysql/charsets/Index.xml from install of MySQL-server-community-5.1.46-1.rhel4.i386 conflicts with file from package mysql-libs-5.0.51a-1.fc9.i386 file /usr/share/mysql/charsets/README from install of MySQL-server-community-5.1.46-1.rhel4.i386 conflicts with file from package mysql-libs-5.0.51a-1.fc9.i386 file /usr/share/mysql/charsets/cp1250.xml from install of MySQL-server-community-5.1.46-1.rhel4.i386 conflicts with file from package mysql-libs-5.0.51a-1.fc9.i386 file /usr/share/mysql/czech/errmsg.sys from install of MySQL-server-community-5.1.46-1.rhel4.i386 conflicts with file from package mysql-libs-5.0.51a-1.fc9.i386 file /usr/share/mysql/danish/errmsg.sys from install of MySQL-server-community-5.1.46-1.rhel4.i386 conflicts with file from package mysql-libs-5.0.51a-1.fc9.i386 file /usr/share/mysql/dutch/errmsg.sys from install of MySQL-server-community-5.1.46-1.rhel4.i386 conflicts with file from package mysql-libs-5.0.51a-1.fc9.i386 file /usr/share/mysql/english/errmsg.sys from install of MySQL-server-community-5.1.46-1.rhel4.i386 conflicts with file from package mysql-libs-5.0.51a-1.fc9.i386 file /usr/share/mysql/estonian/errmsg.sys from install of MySQL-server-community-5.1.46-1.rhel4.i386 conflicts with file from package mysql-libs-5.0.51a-1.fc9.i386 file /usr/share/mysql/french/errmsg.sys from install of MySQL-server-community-5.1.46-1.rhel4.i386 conflicts with file from package mysql-libs-5.0.51a-1.fc9.i386 file /usr/share/mysql/german/errmsg.sys from install of MySQL-server-community-5.1.46-1.rhel4.i386 conflicts with file from package mysql-libs-5.0.51a-1.fc9.i386 file /usr/share/mysql/greek/errmsg.sys from install of MySQL-server-community-5.1.46-1.rhel4.i386 conflicts with file from package mysql-libs-5.0.51a-1.fc9.i386 file /usr/share/mysql/hungarian/errmsg.sys from install of MySQL-server-community-5.1.46-1.rhel4.i386 conflicts with file from package mysql-libs-5.0.51a-1.fc9.i386 file /usr/share/mysql/italian/errmsg.sys from install of MySQL-server-community-5.1.46-1.rhel4.i386 conflicts with file from package mysql-libs-5.0.51a-1.fc9.i386 file /usr/share/mysql/japanese/errmsg.sys from install of MySQL-server-community-5.1.46-1.rhel4.i386 conflicts with file from package mysql-libs-5.0.51a-1.fc9.i386 file /usr/share/mysql/korean/errmsg.sys from install of MySQL-server-community-5.1.46-1.rhel4.i386 conflicts with file from package mysql-libs-5.0.51a-1.fc9.i386 file /usr/share/mysql/norwegian-ny/errmsg.sys from install of MySQL-server-community-5.1.46-1.rhel4.i386 conflicts with file from package mysql-libs-5.0.51a-1.fc9.i386 file /usr/share/mysql/norwegian/errmsg.sys from install of MySQL-server-community-5.1.46-1.rhel4.i386 conflicts with file from package mysql-libs-5.0.51a-1.fc9.i386 file /usr/share/mysql/polish/errmsg.sys from install of MySQL-server-community-5.1.46-1.rhel4.i386 conflicts with file from package mysql-libs-5.0.51a-1.fc9.i386 file /usr/share/mysql/portuguese/errmsg.sys from install of MySQL-server-community-5.1.46-1.rhel4.i386 conflicts with file from package mysql-libs-5.0.51a-1.fc9.i386 file /usr/share/mysql/romanian/errmsg.sys from install of MySQL-server-community-5.1.46-1.rhel4.i386 conflicts with file from package mysql-libs-5.0.51a-1.fc9.i386 file /usr/share/mysql/russian/errmsg.sys from install of MySQL-server-community-5.1.46-1.rhel4.i386 conflicts with file from package mysql-libs-5.0.51a-1.fc9.i386 file /usr/share/mysql/serbian/errmsg.sys from install of MySQL-server-community-5.1.46-1.rhel4.i386 conflicts with file from package mysql-libs-5.0.51a-1.fc9.i386 file /usr/share/mysql/slovak/errmsg.sys from install of MySQL-server-community-5.1.46-1.rhel4.i386 conflicts with file from package mysql-libs-5.0.51a-1.fc9.i386 file /usr/share/mysql/spanish/errmsg.sys from install of MySQL-server-community-5.1.46-1.rhel4.i386 conflicts with file from package mysql-libs-5.0.51a-1.fc9.i386 file /usr/share/mysql/swedish/errmsg.sys from install of MySQL-server-community-5.1.46-1.rhel4.i386 conflicts with file from package mysql-libs-5.0.51a-1.fc9.i386 file /usr/share/mysql/ukrainian/errmsg.sys from install of MySQL-server-community-5.1.46-1.rhel4.i386 conflicts with file from package mysql-libs-5.0.51a-1.fc9.i386

       显然,我们并没有成功安装server包。原因可以分析控制台输出的内容:我们可以判断的出是Fedora 9自带了MySQL5.0.51a,我们安装的MySQL5.1.46与之冲突,怎么办,那我们用自带的吧,才发现没办法启动MySQL,我的原因是在装Fedora9时没有装完整,肯定不至于再装一遍,那就只好装自己的版本。而且,本文不讨论怎样启动自带MySQL,只讨论如何卸载和安装自己的版本,哈哈~

 

       3)要装自己的版本,首先要把原来的版本卸载掉,然而发现没能成功,提示是删除时候,需要依赖一个php-mysql-5.2.5-7.fc9.i386.rpm包。这句话意思不甚明显,感觉是让装个php-mysql-5.2.5-7.fc9.i386.rpm

     [root@localhost install]# rpm -e mysql-libs error: Failed dependencies: libmysqlclient.so.15 is needed by (installed) php-mysql-5.2.5-7.fc9.i386 libmysqlclient.so.15(libmysqlclient_15) is needed by (installed) php-mysql-5.2.5-7.fc9.i386

 

    (4)于是,我就开始疯狂地找php-mysql-5.2.5-7.fc9.i386.rpm啊,网上下载不到,后来想到可以在安装LinuxISO镜像文件里面找。加载虚拟光驱,我的一阵好找,终于找到。赶紧安装,却发现又没成功,分析一下错误输出,才发现php-mysql-5.2.5-7.fc9.i386.rpm本身已经安装了,我们是需要先把它卸载。——|||

 [root@localhost install]# rpm -ivh php-mysql-5.2.5-7.fc9.i386.rpm Preparing... ########################################### [100%] package php-mysql-5.2.5-7.fc9.i386 is already installed

 

 

    此时删除自带版本的MySQL,肯定还和刚才一样的问题。

  [root@localhost install]# rpm -e mysql-libs error: Failed dependencies: libmysqlclient.so.15 is needed by (installed) php-mysql-5.2.5-7.fc9.i386 libmysqlclient.so.15(libmysqlclient_15) is needed by (installed) php-mysql-5.2.5-7.fc9.i386   

 

       5)卸载php-mysql-5.2.5-7.fc9.i386.rpm,没有出错,Happy啊,看来,操作是对的。

  [root@localhost install]# rpm -e php-mysql

  

    (6)这次我们成功地把Fedora自带的MySQL卸载了。

 [root@localhost install]# rpm -e mysql-libs

 

         7)那我们就可以先安装主服务包MySQL-server-community-5.1.46-1.rhel4.i386.rpm,这次没有遇到最初的那种情况,安装进行的很顺利。

 [root@localhost install]# rpm -ivh MySQL-server-community-5.1.46-1.rhel4.i386.rpm Preparing... ########################################### [100%] 1:MySQL-server-community ########################################### [100%] 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 localhost.localdomain 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 with the /usr/bin/mysqlbug script! Starting MySQL..[确定] Giving mysqld 2 seconds to start

 

        8)看控制台最后一句输出内容,MySQL已经启动了,那么我们看一下进程里面是否存在。嘿,一切正常。

 [root@localhost install]# ps -ef | grep mysql root 6517 1 0 16:39 pts/1 00:00:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --pid-file=/var/lib/mysql/localhost.localdomain.pid mysql 6572 6517 0 16:39 pts/1 00:00:00 /usr/sbin/mysqld --basedir=/ --datadir=/var/lib/mysql --user=mysql --log-error=/var/lib/mysql/localhost.localdomain.err --pid-file=/var/lib/mysql/localhost.localdomain.pid root 6683 5226 0 16:42 pts/1 00:00:00 grep mysql

  

   (9)如果不放心,我们可以再确认一下RPM包是否已经成功安装了,但是没有成功,原因是Linux是对大小写敏感的系统mysql的小写形式是不对的。

 [root@localhost install]# rpm -qa | grep mysql (注意大小写) [root@localhost install]# rpm -qa | grep MySQL MySQL-server-community-5.1.46-1.rhel4.i386

  

10)这时再安装客户端包MySQL-client-community-5.1.46-1.rhel5.i386.rpm,依然很顺利。

  [root@localhost install]# rpm -ivh MySQL-client-community-5.1.46-1.rhel5.i386.rpm Preparing... ########################################### [100%] 1:MySQL-client-community ########################################### [100%]

  

11OK,到此,我们已经成功了安装了主服务器包和客户端包,那么我们就可以来体验一下MySQL了。

  [root@localhost install]# mysql Welcome to the MySQL monitor. Commands end with ; or /g. Your MySQL connection id is 1 Server version: 5.1.46-community MySQL Community Server (GPL) Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. This software comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to modify and redistribute it under the GPL v2 license Type 'help;' or '/h' for help. Type '/c' to clear the current input statement. mysql> mysql> show databases -> ; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | test | +--------------------+ 3 rows in set (0.00 sec)

     不错不错,成功执行了查询。

 

       12MySQL默认情况为随系统的启动而启动,可以通过chkconfig --list mysql命令查看、查看MySQL进程、关闭、打开MySQL的操作如下所示:

[root@localhost ~]# chkconfig --list mysql mysql 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭 [root@localhost install]# ps -el | grep mysqld 0 S 0 7112 1 0 80 0 - 1545 wait pts/1 00:00:00 mysqld_safe 4 S 501 7167 7112 0 80 0 - 31823 select pts/1 00:00:00 mysqld [root@localhost ~]# service mysql stop Shutting down MySQL..... . [确定] [root@localhost install]# service mysql start Starting MySQL. [确定]

你可能感兴趣的:(mysql,linux,server,File,service,dependencies)