下面是我在学习中获取的小知识哦,在这里和大家进行一个分享,如果还有不懂,那请看一下: 网络课程
 
在linux下安装mysql中,与旧版本冲突的一些简单的解决办法
后附DBI作用。

下载了针对rhel4的mysql5.1.50的server包和client包,传到/root下,安装,发现与以前版本冲突,那么应该:

[root@localhost ~]# ls
anaconda-ks.cfg  install.log         MySQL-client-community-5.1.50-1.rhel4.i386.rpm
Desktop          install.log.syslog  MySQL-server-community-5.1.50-1.rhel4.i386.rpm
[root@localhost ~]# rpm -ivh My*
warning: MySQL-client-community-5.1.50-1.rhel4.i386.rpm: V3 DSA signature: NOKEY, key ID 5072e1f5
error: Failed dependencies:
        MySQL conflicts with mysql-4.1.20-1.RHEL4.1.i386
        MySQL-server conflicts with mysql-server-4.1.20-1.RHEL4.1.i386

[root@localhost ~]# rpm -ivh MySQL-server-community-5.1.50-1.rhel4.i386.rpm
warning: MySQL-server-community-5.1.50-1.rhel4.i386.rpm: V3 DSA signature: NOKEY, key ID 5072e1f5
error: Failed dependencies:
        MySQL conflicts with mysql-4.1.20-1.RHEL4.1.i386
        MySQL-server conflicts with mysql-server-4.1.20-1.RHEL4.1.i386

试试升级安装,也不行,那么就:
[root@localhost ~]# rpm -Uvh MySQL-server-community-5.1.50-1.rhel4.i386.rpm
warning: MySQL-server-community-5.1.50-1.rhel4.i386.rpm: V3 DSA signature: NOKEY, key ID 5072e1f5
error: Failed dependencies:
        libmysqlclient.so.14 is needed by (installed) mod_auth_mysql-2.6.1-2.2.i386
        libmysqlclient.so.14 is needed by (installed) php-mysql-4.3.9-3.15.i386
        libmysqlclient.so.14 is needed by (installed) cyrus-sasl-sql-2.1.19-5.EL4.i386
        libmysqlclient.so.14 is needed by (installed) dovecot-0.99.11-4.EL4.i386
        libmysqlclient.so.14 is needed by (installed) perl-DBD-MySQL-2.9004-3.1.i386
        libmysqlclient.so.14 is needed by (installed) freeradius-mysql-1.0.1-3.RHEL4.3.i386
        libmysqlclient.so.14(libmysqlclient_14) is needed by (installed) php-mysql-4.3.9-3.15.i386


那就只有先卸掉冲突的包,先查看一下相关的包:
[root@localhost ~]# rpm -qa |grep perl-DB*
perl-Digest-SHA1-2.07-5
perl-DBI-1.40-8
perl-DateManip-5.42a-3
perl-DBD-MySQL-2.9004-3.1
perl-Digest-HMAC-1.01-13
perl-DBD-Pg-1.31-6
perl-Date-Calc-5.3-9


[root@localhost ~]# rpm -e perl-DBD-MySQL-2.9004-3.1
error: Failed dependencies:
        perl-DBD-MySQL is needed by (installed) mysql-server-4.1.20-1.RHEL4.1.i386
卸不掉,此包被mysql-server-4.1.20-1.RHEL4.1.i386依赖,于是把它们一起卸载,-e后的包顺序无所谓,linux会自己协调处理:      
        
[root@localhost ~]# rpm -e perl-DBD-MySQL-2.9004-3.1 mysql-server-4.1.20-1.RHEL4.1.i386

卸载成功。

[root@localhost ~]# rpm -qa |grep perl-DB*
perl-Digest-SHA1-2.07-5
perl-DBI-1.40-8
perl-DateManip-5.42a-3
perl-Digest-HMAC-1.01-13
perl-DBD-Pg-1.31-6
perl-Date-Calc-5.3-9

重新安装,还是有依赖关系问题:
[root@localhost ~]# rpm -ivh M*
warning: MySQL-client-community-5.1.50-1.rhel4.i386.rpm: V3 DSA signature: NOKEY, key ID 5072e1f5
error: Failed dependencies:
        MySQL conflicts with mysql-4.1.20-1.RHEL4.1.i386

再看看相关的包:
[root@localhost ~]# rpm -qa |grep perl-DB*
perl-Digest-SHA1-2.07-5
perl-DBI-1.40-8
perl-DateManip-5.42a-3
perl-Digest-HMAC-1.01-13
perl-DBD-Pg-1.31-6
perl-Date-Calc-5.3-9

于是继续卸载
[root@localhost ~]# rpm -e perl-DBI-1.40-8
error: Failed dependencies:
        perl(DBI) is needed by (installed) mysql-4.1.20-1.RHEL4.1.i386
        perl(DBI) is needed by (installed) mysql-bench-4.1.20-1.RHEL4.1.i386
        perl(DBI) is needed by (installed) perl-DBD-Pg-1.31-6.i386
        perl-DBI is needed by (installed) perl-DBD-Pg-1.31-6.i386

又被几个包依赖,于是把它们加上再卸载,这些包也被依赖:

[root@localhost ~]# rpm -e perl-DBI-1.40-8 mysql-4.1.20-1.RHEL4.1.i386 mysql-bench-4.1.20-1.RHEL4.1.i386 perl-DBD-Pg-1.31-6.i386 perl-DBD-Pg-1.31-6.i386
error: Failed dependencies:
        libmysqlclient.so.14 is needed by (installed) mod_auth_mysql-2.6.1-2.2.i386
        libmysqlclient.so.14 is needed by (installed) php-mysql-4.3.9-3.15.i386
        libmysqlclient.so.14 is needed by (installed) cyrus-sasl-sql-2.1.19-5.EL4.i386
        libmysqlclient.so.14 is needed by (installed) dovecot-0.99.11-4.EL4.i386
        libmysqlclient.so.14 is needed by (installed) freeradius-mysql-1.0.1-3.RHEL4.3.i386
        libmysqlclient.so.14(libmysqlclient_14) is needed by (installed) php-mysql-4.3.9-3.15.i386
        mysql = 4.1.20-1.RHEL4.1 is needed by (installed) mysql-devel-4.1.20-1.RHEL4.1.i386
        mysql is needed by (installed) freeradius-mysql-1.0.1-3.RHEL4.3.i386

于是把它们再次一起卸载,把这些包写入一行,终于成功了!:


rpm -e perl-DBI-1.40-8 mysql-4.1.20-1.RHEL4.1.i386 mysql-bench-4.1.20-1.RHEL4.1.i386 perl-DBD-Pg-1.31-6.i386 perl-DBD-Pg-1.31-6.i386       mod_auth_mysql-2.6.1-2.2.i386         php-mysql-4.3.9-3.15.i386         cyrus-sasl-sql-2.1.19-5.EL4.i386         dovecot-0.99.11-4.EL4.i386         freeradius-mysql-1.0.1-3.RHEL4.3.i386       php-mysql-4.3.9-3.15.i386        mysql-devel-4.1.20-1.RHEL4.1.i386        freeradius-mysql-1.0.1-3.RHEL4.3.i386

然后执行mysql5的安装,终于成功!:
[root@localhost ~]# ls
anaconda-ks.cfg  install.log         MySQL-client-community-5.1.50-1.rhel4.i386.rpm
Desktop          install.log.syslog  MySQL-server-community-5.1.50-1.rhel4.i386.rpm
[root@localhost ~]# rpm -ivh M*
warning: MySQL-client-community-5.1.50-1.rhel4.i386.rpm: V3 DSA signature: NOKEY, key ID 5072e1f5
Preparing...                ########################################### [100%]
   1:MySQL-server-community ########################################### [ 50%]

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 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!



Notes regarding SELinux on this platform:
=========================================

The default policy might cause server startup to fail because it is
not allowed to access critical files. In this case, please update
your installation.

The default policy might also cause inavailability of SSL related
features because the server is not allowed to access /dev/random
and /dev/urandom. If this is a problem, please do the following:

  1) install selinux-policy-targeted-sources from your OS vendor
  2) add the following two lines to /etc/selinux/targeted/src/policy/domains/program/mysqld.te:
       allow mysqld_t random_device_t:chr_file read;
       allow mysqld_t urandom_device_t:chr_file read;
  3) cd to /etc/selinux/targeted/src/policy and issue the following command:
       make load


Starting MySQL..[  OK  ]
Giving mysqld 2 seconds to start
   2:MySQL-client-community ########################################### [100%]
[root@localhost ~]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.50-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> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| test               |
+--------------------+
3 rows in set (0.01 sec)

mysql> exit
Bye


DBI的一些简单应用:
编写一些能够访问MySQL数据库的Perl脚本,就需要安装DBI模块

什么是DBI呢?
答:简单的说,以下答案引自DBI的作者Tim Bunce:"DBI是用于Perl语言、操作数据库的应用程序
接口(API)。DBI API规范定义了一套函数(functions),变量和协定, 提供了一个稳定的
数据库接口而不必考虑实际使用什么样的数据库" 用更精炼的语言来描述就是,DBI作为
Perl语言的接口,允许使用者不需要更改程序就可以操作不同的数据库。
以上的知识是不是对大家有起到作用呢,希望能很好的帮助大家····