入门级
部门级
企业级
特种服务器
其它

五大核心
Web服务器
FTP服务器
Mail服务器
域名服务器
文件共享服务器
其它
路由器应用
代理服务器
数据库

Windows阵营
Unix
Linux
你的位置: 软件> 服务器软件> Linux系列>
RedHat Linux 网络服务器构架实务(三)
2002-02-06 17:16:00· 赵凤君· Yesky

上一页  1 2 3 4 5 6 7 8 9 10 11 12  下一页

  vi config.inc.php

  $cfgServers[1]['host']   = 'localhost';  // 主机名
  $cfgServers[1]['port']   = '3306';    // 默认端口
  $cfgServers[1]['socket']  = '';      // 使用的socket路径
  $cfgServers[1]['connect_type'] = 'tcp';   //使用tcp还是 socket方式来连接
  $cfgServers[1]['stduser']   = ' ';    // 标准用户帐号名称
  $cfgServers[1]['stdpass']   = ' ';    // 标准帐号的密码
  $cfgServers[1]['auth_type']  = 'http';  //指定验证方式为config, http 还是 cookie,这是2.2.3版本的一个变化,比较安全的方式是http验证
  $cfgServers[1]['user']     = 'root';   // MySQL 帐号
  $cfgServers[1]['password']   = ' ';    // 只有使用config验证方式的时候才需要填写
  $cfgServers[1]['only_db']   = '';     // 如果你在这里指定了一个数据库,那么登陆后系统只列出这个数据库在左侧

  6 测试phpMyAdmin
  apache restart
  lynx http://mysql.yesgo.loc      //建议使用客户端浏览器测试

  Step 16 Server Test

  ## 为什么不使用 1+1=<%=1+1%>或者<%out.print("Hello World!");%>这样的例子呢? 因为这样的例子只能测试Apache和Resin是否能够协同工作,而不能测试数据库连接、JDBC2.0是否支持,中文问题是否存在等等。下面给出四个例子,第一个例子可以测试上述的所有问题;第二个例子告诉你如何使用Resin的连接池;第三个例子告诉你如何调用组件,如何实现数据层和处理层的分离;第四个例子用来测试PHP。

  例一:使用连接串连接数据库

  1 创建数据库
  ## 数据库脚本如下,可存储为.sql文件,然后利用phpMyAdmin生成数据库
  ## 注意,后面的例子也将沿用该数据库。
  create database yesgo
  use yesgo;

  create table prov
  (
  prov_id  tinyint(2)  not null  primary key,
  prov_name  char(6)  not null
  );

  insert into prov values ('01','安徽');
  insert into prov values ('02','北京');
  insert into prov values ('03','重庆');
  insert into prov values ('04','福建');
  insert into prov values ('05','甘肃');
  insert into prov values ('06','广东');
  insert into prov values ('07','广西');
  insert into prov values ('08','贵州');
  insert into prov values ('09','海南');
  insert into prov values ('10','河北');
  insert into prov values ('11','黑龙江');
  insert into prov values ('12','河南');
  insert into prov values ('13','湖北');
  insert into prov values ('14','湖南');
  insert into prov values ('15','内蒙古');
  insert into prov values ('16','江苏');
  insert into prov values ('17','江西');
  insert into prov values ('18','吉林');
  insert into prov values ('19','辽宁');
  insert into prov values ('20','宁夏');
  insert into prov values ('21','青海');
  insert into prov values ('22','山西');
  insert into prov values ('23','陕西');
  insert into prov values ('24','山东');
  insert into prov values ('25','上海');
  insert into prov values ('26','四川');
  insert into prov values ('27','天津');
  insert into prov values ('28','西藏');
  insert into prov values ('29','新疆');
  insert into prov values ('30','云南');
  insert into prov values ('31','浙江');
  insert into prov values ('32','香港');
  insert into prov values ('33','澳门');
  insert into prov values ('34','台湾');

  2 为数据库添加帐号
  ##按如下方式添加的帐户只对yesgo数据库具有权限,而且对它拥有全部权限。但为什么要添加四次呢?主要是host的不同,需要注意的是,MySQL验证是一个连接是否正确,不仅取决于帐号和密码,还要看主机名和数据库名。
  mysql -p
  mysql> grant all privileges on yesgo.* to your_user_name@localhost identified by 'your_password' with grant option;
  mysql> grant all privileges on yesgo.* to your_user_name@'ns.yesgo.loc' identified by 'your_password' with grant option;
  mysql> grant all privileges on yesgo.* to your_user_name@'192.168.1.2' identified by 'your_password' with grant option;
  mysql> grant all privileges on yesgo.* to your_user_name@'%'identified by 'your_password' with grant option;
  mysql>exit

  3 创建JSP源文件
  touch /home/www/cnmysql.jsp
  chown -R www /home/www/cnmysql.jsp
  chgrp -r root /home/www/cnmysql.jsp
  chmod 771 /home/www/cnmsql.jsp

上一页  1 2 3 4 5 6 7 8 9 10 11 12  下一页


■ 相关内容