Chinaunix首页 | 论坛 | 博客
  • 博客访问: 164612
  • 博文数量: 34
  • 博客积分: 310
  • 博客等级: 二等列兵
  • 技术积分: 255
  • 用 户 组: 普通用户
  • 注册时间: 2011-12-09 01:00
文章分类

全部博文(34)

文章存档

2012年(19)

2011年(15)

分类:

2011-12-09 01:02:38

原文地址:tomcat 连接mysql 数据库.(一) 作者:doita

   之前写过tomcat httpd mysql组合的基本安装,后发现写的不好,便重新写了下,把每个细节尽量搞清楚,就有了前面几篇关于apache 的东西,即将进行的是,
1.  mysql的编译安装
2.  在tomcat上部署有连接db的应用.并成功连接数据库.

自己正在学习大学时候没有选的课j2ee,当时为什么不选呢?
第一部分.mysql编译安装.
    在以前个人比较推荐rpm包或者yum安装,一般来讲这样的安装结果总不会太糟糕,当然也不是最符合你需要的安装方法,开源的的最大魅力在于你的掌控力跟你的能力成正比,菜鸟当然只能慢慢探索,很明显我是菜鸟.只能一点一点的来,写的东西都断断续续的.分成好几份.
    mysql编译安装链接: http://dev.mysql.com/doc/refman/5.1/zh/installing.html#linux-rpm
 [root@doita ~]#groupadd -g 505 mysql
  1. [root@doita ~]#useradd -u 505 -g mysql mysql
  2. [root@doita mysql-5.1.60]#./configure --prefix=/opt/mysql-5.1.60 --with-plugins=all
  3. 为了让mysql支持innodb.喝一口凉开水.
  4. 出现错误
  5. checking for tgetent in -ltermcap... no
  6. checking for tgetent in -ltinfo... no
  7. checking for termcap functions library... configure: error: No curses/termcap library found

原因:

缺少ncurses安装包

 

解决办法:

下载安装相应软件包

一、如果你的系统是RedHat系列:

yum list|grep ncurses

yum -y install ncurses-devel

yum install ncurses-devel

 

二、如果你的系统是UbuntuDebian

apt-cache search ncurses

apt-get install libncurses5-dev


解决以上依赖问题之后,继续安装

make  &&
make install

继续进行配置,

在解压好的源码包里面,将support-files/my-medium.cnf 拷贝到 /etc/my.cnf ,里面有large ,medium,和small 三种配置组合,genjuserver性能量力而为.


 拷贝  support-files/mysql.server 为 /etc/init.d/mysqld


在mysql的源码包中,运行scripts/mysql_install_db ,对数据库进行初始化.(据官方文档,应该执行安装后目录的bin/mysql_install_db,二者是一样的)

  1. [root@doita scripts]#./mysql_install_db
  2. Installing MySQL system tables...
  3. 111206 20:40:46 [Warning] '--skip-locking' is deprecated and will be removed in a future release. Please use '--skip-external-locking' instead.
  4. OK
  5. Filling help tables...
  6. 111206 20:40:46 [Warning] '--skip-locking' is deprecated and will be removed in a future release. Please use '--skip-external-locking' instead.
  7. OK

  8. To start mysqld at boot time you have to copy
  9. support-files/mysql.server to the right place for your system

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

  12. /opt/mysql-5.1.60/bin/mysqladmin -u root password 'new-password'
  13. /opt/mysql-5.1.60/bin/mysqladmin -u root -h doita password 'new-password'

  14. Alternatively you can run:
  15. /opt/mysql-5.1.60/bin/mysql_secure_installation

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

  19. See the manual for more instructions.

  20. You can start the MySQL daemon with:
  21. cd /opt/mysql-5.1.60 ; /opt/mysql-5.1.60/bin/mysqld_safe &

  22. You can test the MySQL daemon with mysql-test-run.pl
  23. cd /opt/mysql-5.1.60/mysql-test ; perl mysql-test-run.pl

  24. Please report any problems with the /opt/mysql-5.1.60/bin/mysqlbug

修改安装目录权限,如下

[root@doita mysql-5.1.60]#ls -ltr
total 32
drwxr-x---  3 root  mysql 4096 Dec  6 06:47 include
drwxr-x---  3 root  mysql 4096 Dec  6 06:47 lib
drwxr-x---  2 root  mysql 4096 Dec  6 06:48 bin
drwxr-x--- 10 root  mysql 4096 Dec  6 06:49 mysql-test
drwxr-x---  6 root  mysql 4096 Dec  6 06:49 share
drwxr-x---  5 root  mysql 4096 Dec  6 06:50 sql-bench
drwxr-x---  2 root  mysql 4096 Dec  6 06:50 libexec
drwxr-x---  4 mysql mysql 4096 Dec  6 21:01 var


为账号设置密码.

在 bin目录下运行 

mysqladmin -u root password "newpasswd" 

就可以进行基本的使用了.




 




阅读(1602) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~