linux未安装MySQL但有进程_Linux_RedHat下安装MySQL出现的问题及解决方法

本文介绍了在Linux RedHat系统中遇到的MySQL安装问题,包括未安装MySQL但有进程的情况,如何卸载残留文件,以及解决依赖错误的方法。此外,还涉及到数据库连接配置,使用Hibernate和JDBC,以及MySQL的自动启动设置。在解决启动问题时,提到了可能需要关闭SELINUX,并解决启动依赖问题。
摘要由CSDN通过智能技术生成

# rpm -e MySQL-server-community-5.0.82-0.rhel5

#rpm -e MySQL-client-community-5.0.82-0.rhel5

卸载后/var/lib/mysql中的数据及/etc/my.cnf不会删除,如果确定没用

后就手工删除

rm -f /etc/my.cnf

rm -rf /var/lib/mysql

介绍一下mysql安装完后的几个目录

1)数据库目录

/var/lib/mysql/

2)配置文件

/usr/share/mysql(mysql.server命令及配置文件)

3)相关命令

/usr/bin(mysqladmin mysqldump等命令)

4)启动脚本

/etc/rc.d/init.d/(启动脚本文件mysql的目录)

我从这些目录中把带mysql的文件都删除了

用sudo rm –f mysql;

2.数据库连接配置

数据库连接采用了hibernate和JDBC两种方式

Hibernate的话更改配置很方便,但是JDBC如果用class.forName的方式则不利用程序的移植,数据库地址改了的话还得重新编译,所以采用了JNDI

在tomcat的context.xml中加入

type="javax.sql.DataSource" driverClassName="com.mysql.jdbc.Driver"

url="jdbc:mysql://10.2.1.10:3306/pcms?useUnicode=true&characterEncoding=UTF-8"

username="root" password="" maxActive="20" maxIdle="10"

maxWait="-1"/>即可。

注意url部分,在xml文件中&需写成&

而在java程序中只需用&

程序中写成:

public static Connection getConnection()

{

Connection cs=null;

try{

Context ctx = new InitialContext();

//JNDI ok

DataSource ds = (DataSource) ctx.lookup("java:comp/env/jdbc/pcms");

cs = ds.getConnection();

}catch(SQLException se)

{

se.getMessage();

} catch (NamingException e) {

e.printStackTrace();

}

return cs;

}

3.MySQL启动问题

MySQL安装完后就是随系统自动启动了的,如果没有的话需要做一点设置:

让mysql自动启动

# cp /usr/local/share/mysql/mysql.server /etc/init.d/mysqld

#chkconfig mysqld on

4.安装过程中出现的错误及解决方法

Starting MySQL.Manager of pid-file quit without updating fi[FAILED]

上网查了很多方法 一种是打开/etc/selinux/config把SELINUX=enforcing改为SELINUX=disabled后存盘退出重启机器后问题就得以解决。

貌似解决了,上次去部署工程的时候在名字节点上就是这样改的。

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)这是没启动mysql的守护进程,执行service mysqld start就行了!

[root@HPDS-1 myang]# rpm -ivh MySQL-server-5i386.rpm

error: Failed dependencies:

/bin/sh is needed by MySQL-server-community-5.0.82-0.rhel5.i386

/usr/bin/perl is needed by MySQL-server-community-5.0.82-0.rhel5.i386

chkconfig is needed by MySQL-server-community-5.0.82-0.rhel5.i386

coreutils is needed by MySQL-server-community-5.0.82-0.rhel5.i386

grep is needed by MySQL-server-community-5.0.82-0.rhel5.i386

libc.so.6 is needed by MySQL-server-community-5.0.82-0.rhel5.i386

libc.so.6(GLIBC_2.0) is needed by MySQL-server-community-5.0.82-0.rhel5.i386

libc.so.6(GLIBC_2.1) is needed by MySQL-server-community-5.0.82-0.rhel5.i386

libc.so.6(GLIBC_2.1.2) is needed by MySQL-server-community-5.0.82-0.rhel5.i386

libc.so.6(GLIBC_2.1.3) is needed by MySQL-server-community-5.0.82-0.rhel5.i386

libc.so.6(GLIBC_2.2) is needed by MySQL-server-community-5.0.82-0.rhel5.i386

libc.so.6(GLIBC_2.3) is needed by MySQL-server-community-5.0.82-0.rhel5.i386

libc.so.6(GLIBC_2.3.4) is needed by MySQL-server-community-5.0.82-0.rhel5.i386

libc.so.6(GLIBC_2.4) is needed by MySQL-server-community-5.0.82-0.rhel5.i386

libcrypt.so.1 is needed by MySQL-server-community-5.0.82-0.rhel5.i386

libcrypt.so.1(GLIBC_2.0) is needed by MySQL-server-community-5.0.82-0.rhel5.i386

libdl.so.2 is needed by MySQL-server-community-5.0.82-0.rhel5.i386

libdl.so.2(GLIBC_2.0) is needed by MySQL-server-community-5.0.82-0.rhel5.i386

libdl.so.2(GLIBC_2.1) is needed by MySQL-server-community-5.0.82-0.rhel5.i386

libm.so.6 is needed by MySQL-server-community-5.0.82-0.rhel5.i386

libm.so.6(GLIBC_2.0) is needed by MySQL-server-community-5.0.82-0.rhel5.i386

libm.so.6(GLIBC_2.1) is needed by MySQL-server-community-5.0.82-0.rhel5.i386

libnsl.so.1 is needed by MySQL-server-community-5.0.82-0.rhel5.i386

libpthread.so.0 is needed by MySQL-server-community-5.0.82-0.rhel5.i386

libpthread.so.0(GLIBC_2.0) is needed by MySQL-server-community-5.0.82-0.rhel5.i386

libpthread.so.0(GLIBC_2.1) is needed by MySQL-server-community-5.0.82-0.rhel5.i386

libpthread.so.0(GLIBC_2.2) is needed by MySQL-server-community-5.0.82-0.rhel5.i386

libpthread.so.0(GLIBC_2.3.2) is needed by MySQL-server-community-5.0.82-0.rhel5.i386

librt.so.1 is needed by MySQL-server-community-5.0.82-0.rhel5.i386

procps is needed by MySQL-server-community-5.0.82-0.rhel5.i386

rtld(GNU_HASH) is needed by MySQL-server-community-5.0.82-0.rhel5.i386

shadow-utils is needed by MySQL-server-community-5.0.82-0.rhel5.i386

============================================================================================

强制安装

那试试

rpm -ivh *.rpm --force --nodeps

/替换

rpm -ivh --replacefiles **.rpm

这个问题上次出现了,今天去却没出现 怪异了 不知道是不是和设置了selinux=disabled有关

还没验证过上面的方法。

分享到:

18e900b8666ce6f233d25ec02f95ee59.png

72dd548719f0ace4d5f9bca64e1d7715.png

2009-06-18 22:57

浏览 3913

评论

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值