# 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有关
还没验证过上面的方法。
分享到:
2009-06-18 22:57
浏览 3913
评论