Linux下java web服务器搭建(MySQL5.1)

1 篇文章 0 订阅

原创文章,转载请注明出处:http://www.aj2ee.com


Linux下java web服务器搭建(JDK1.6、MySQL5.1、Apache2.2+2Tomcat6+svn1.5)

三、MySQL的安装与配置

1、下载MySQL的安装文件

  安装MySQL需要下面两个文件:

    MySQL-server-community-5.1.61-1.rhel5.i386.rpm

    MySQL-client-community-5.1.61-1.rhel5.i386.rpm

  1)安装服务器端

  在有两个rmp文件的目录下运行如下命令:

  rpm -ivh MySQL-server-community-5.1.61-1.rhel5.i386.rpm

[root@localhost ~]# cd /home 
[root@localhost home]# rpm -ivh MySQL-server-community-5.1.61-1.rhel5.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 
[root@localhost home]# 

 显示如下信息。

 2)安装客户端

  运行如下命令:

 rpm -ivh MySQL-client-community-5.1.61-1.rhel5.i386.rpm

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

  显示安装完毕。

2、登录MySQL

  登录MySQL的命令是mysql,mysql 的使用语法如下:

  mysql [-u username] [-h host] [-p[password]] [dbname]

  username 与 password 分别是 MySQL 的用户名与密码,mysql的初始管理帐号是root,没有密码,注意:这个root用户不是Linux的系统用户。MySQL默认用户是root,由于初始没有密码,第一次进时只需键入mysql即可。

[root@localhost home]# mysql 
Welcome to the MySQL monitor.  Commands end with ; or \g. 
Your MySQL connection id is 1 
Server version: 5.1.61-community MySQL Community Server (GPL) 
 
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 
 
Oracle is a registered trademark of Oracle Corporation and/or its 
affiliates. Other names may be trademarks of their respective 
owners. 
 
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. 
 
mysql> 
  
出现了“mysql>”提示符,恭喜你,安装成功!

   修改MySQL root用户的密码

MySQL默认没有密码,安装完毕增加密码的重要性是不言而喻的。

命令usr/bin/mysqladmin -u root password 'new-password'

格式:mysqladmin -u用户名 -p旧密码 password 新密码

示例:mysqladmin -u root password '123456'

这命令的作用是将root用户的密码改成123456

增加了密码后的登录格式如下:

  mysql -u root -p

  Enter password: (输入密码)

  其中-u后跟的是用户名,-p要求输入密码,回车后在输入密码处输入密码。

  注意:这个mysql文件在/usr/bin目录下,与后面讲的启动文件/etc/init.d/mysql不是一个文件。

4.  MySQL的几个重要目录

  MySQL安装完成后不象SQL Server默认安装在一个目录,它的数据库文件、配置文件和命令文件分别在不同的目录,了解这些目录非常重要,尤其对于Linux的初学者,因为Linux本身的目录结构就比较复杂,如果搞不清楚MySQL的安装目录那就无从谈起深入学习。

  下面就介绍一下这几个目录。

  1、数据库目录

  /var/lib/mysql/

  2、配置文件

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

  3、相关命令

  /usr/bin(mysqladmin mysqldump等命令)

  4、启动脚本

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

5.启动与停止

  1、启动

  MySQL安装完成后启动文件mysql在/etc/init.d目录下,在需要启动时运行下面命令即可。

  [root@localhost init.d]# /etc/init.d/mysql start

  2、停止

  /usr/bin/mysqladmin -u root -p shutdown

  3、自动启动

  1)察看mysql是否在自动启动列表中

  [root@localhost local]# /sbin/chkconfig --list

  2)把MySQL添加到你系统的启动服务组里面去

  [root@localhost local]# /sbin/chkconfig --add mysql

  3)把MySQL从启动服务组里面删除。

  [root@localhost local]# /sbin/chkconfig --del mysql

5.MySQL的常用操作。略(数据库的增删改查这里我就不介绍了)


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值