# vim /etc/httpd24/httpd.conf
PidFile "/var/run/httpd/httpd.pid"
LoadModule php5_module        modules/libphp5.so
DocumentRoot "/web/htdocs"
<Directory "/web/htdocs">
# vim /web/htdocs/index.php        #里面的内容是摘抄的
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<p>测试</p>
<table border="1"  width="80%" cellpadding="0">
<tr><td width="10%" align="center">Id</td><td width="20%" align="center">Name</td><td width="10%" align="center">Age</td><td width="10%" align="center">Sex</td><td width="30%" align="center">Address</td><td width="20%" align="center">DoWith</td>
</tr>
<?php//连接数据库//打开一个连接,连接到本地mysql数据库$conn=mysql_connect("www.crwolf.com","root","welcome");//ip,user,pwd//选择操作的资料库        mysql_select_db("table1",$conn);// 资料库名称,连接$sql="select * from test";//用mysql_query函数从资料库中查询mysql_query("set names UTF-8");//处理中文乱码问题,gbk可以是其它值$result=mysql_query($sql,$conn);// search  sql, connection//循环读取记录while($row=mysql_fetch_array($result)){
?><tr><td width="10%" align="center"><?php echo $row["ID"] ?></td><td width="20%" align="center"><?php echo $row["NAME"] ?></td><td width="10%" align="center"><?php echo $row["Age"] ?></td><td width="10%" align="center"><?=$row["SEX"]?></td><td width="30%" align="center"><?=$row["Address"]?></td><td width="20%" align="center"><a href="#" mce_href="#" onClick="<?php    doDel($row["ID"]) ?>">删除</a></td></tr># service httpd24 restart

问题来了,到浏览器输入192.168.1.9

其它的就不显示了。

查看日志

# less error_log

[Wed Apr 08 08:58:56.795374 2015] [:error] [pid 4309] [client 192.168.1.9:58773] PHP Warning:  mysql_connect(): Can't connect to MySQL server on 'www.crwolf.com' (111) in /web/htdocs/index.php on line 15

[Wed Apr 08 08:58:56.795409 2015] [:error] [pid 4309] [client 192.168.1.9:58773] PHP Warning:  mysql_select_db() expects parameter 2 to be resource, boolean given in /web/htdocs/index.php on line 17

[Wed Apr 08 08:58:56.795448 2015] [:error] [pid 4309] [client 192.168.1.9:58773] PHP Warning:  mysql_query(): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) in /web/htdocs/index.php on line 21

[Wed Apr 08 08:58:56.795457 2015] [:error] [pid 4309] [client 192.168.1.9:58773] PHP Warning:  mysql_query(): A link to the server could not be established in /web/htdocs/index.php on line 21

[Wed Apr 08 08:58:56.795475 2015] [:error] [pid 4309] [client 192.168.1.9:58773] PHP Warning:  mysql_query() expects parameter 2 to be resource, boolean given in /web/htdocs/index.php on line 22

[Wed Apr 08 08:58:56.795483 2015] [:error] [pid 4309] [client 192.168.1.9:58773] PHP Warning:  mysql_fetch_array() expects parameter 1 to be resource, null given in /web/htdocs/index.php on line 24

[Wed Apr 08 08:58:56.795490 2015] [:error] [pid 4309] [client 192.168.1.9:58773] PHP Warning:  mysql_close() expects parameter 1 to be resource, boolean given in /web/htdocs/index.php on line 38

好吧,数据库每打开

# service mysqld start        #设置过开机启动,不知道为什么没有用

再到浏览器刷新还是没有用

进入mysql

# mysql
mysql> use mysql
Database changed
mysql> SELECT host,user,password FROM user;
+-------------+-------------+-------------------------------------------+
| host        | user        | password                                  |
+-------------+-------------+-------------------------------------------+
| localhost   | root        | *DF216F57F1F2066124E1AA5491D995C3CB57E4C2 |
| 127.0.0.1   | root        |                                           |
| ::1         | root        |                                           |
| localhost   |             |                                           |
+-------------+-------------+-------------------------------------------+

怎么会没有root用户,www.crwolf.com主机,第一次就创建了,可能不小心给删了,好吧,再重新创建

mysql> create user 'root'@'www.crwolf.com' identified by 'welcome';
ERROR 1396 (HY000): Operation CREATE USER failed for 'root'@'www.crwolf.com'

你妹,这又是怎么回事,网上找了好久,说是bug了,解决方法:把要创建的用户删除一次,再创建,别忘记flush

mysql> drop user 'root'@'www.crwolf.com';    #都没有这个,还要再删除,挺郁闷的
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> create user 'root'@'www.crwolf.com' identified by 'welcome';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> SELECT host,user,password FROM user;
+----------------+-------------+-------------------------------------------+
| host           | user        | password                                  |
+----------------+-------------+-------------------------------------------+
| localhost      | root        | *DF216F57F1F2066124E1AA5491D995C3CB57E4C2 |
| 127.0.0.1      | root        |                                           |
| www.crwolf.com | root        | *DF216F57F1F2066124E1AA5491D995C3CB57E4C2 |
| ::1            | root        |                                           |
| localhost      |             |                                           |
+----------------+-------------+-------------------------------------------+

这次有用户了吧,再刷新页面,怎么还是刚刚的页面,再看日志

# less error_log

[Wed Apr 08 10:14:37.502684 2015] [:error] [pid 5510] [client 192.168.1.9:60334] PHP Warning:  mysql_fetch_array() expects parameter 1 to be resource, boolean given in /web/htdocs/index.php on line 24

[Wed Apr 08 10:18:46.821670 2015] [:error] [pid 5512] [client 192.168.1.9:60351] PHP Warning:  mysql_fetch_array() expects parameter 1 to be resource, boolean given in /web/htdocs/index.php on line 24

登陆数据库的用户没有数据库的权限(这个只是我的,可能还有别的原因),到mysql授权。不解处:root还没有权限?

mysql> use mysql
Database changed
mysql> grant select on table1.test to root  ;
Query OK, 0 rows affected (0.00 sec)

再去刷新页面,终于好了。

转载于:https://blog.51cto.com/523958392/1629939

第二次启用httpd24调用mysql时出现的错误相关推荐

  1. Navicat 连接MySQL时出现1251错误的解决方案

    Navicat 连接MySQL时出现1251错误的解决方案 参考文章: (1)Navicat 连接MySQL时出现1251错误的解决方案 (2)https://www.cnblogs.com/diao ...

  2. Navicat Premium链接MySQL时出现2059错误解决方法

    下面这个是有关Navicat Premium链接MySQL时出现2059错误解决方法的教程(在看该教程之前mysql的配置已完成) 链接MySQL时出现2059错误该怎么解决呢? 提示:以下是本篇文章 ...

  3. navicat for mysql 1045错误,navicat连接mysql时出现1045错误的解决方法

    navicat连接mysql时出现1045错误的解决方法 navicat for MySQL 连接本地数据库出现1045错误 如下图: 查了很多资料,意思是说mysql没有授权远程连接,也就是权限不够 ...

  4. error lnk2001: mysql_使用mysql时的链接错误 | 学步园

    当使用mysql时出现错误: mysqlclient.lib(inftrees.obj) : error LNK2001: unresolved external symbol ___security ...

  5. 从PyUSB调用set_configuration时出现“未知错误”

    本文介绍了Windows 10使用pyusb与USB设备通信时的一个错误处理方法,网上找了很多方法尝试都没能成功解决,故重新整理了一下问题解决方法,期望对大家解决问题具有一定的参考价值. 问题描述 我 ...

  6. JDBC连接MySQL时出现的错误

    我在JDBC编程中,从别的地方导入的java文件运行中遇到的错误. MySQL账号和密码错误"eclipse出现_Access denied for user 'root'@'localho ...

  7. redhat安装pure-ftpd+mysql时出现libmysqlclient错误的解决办法

    redhat as 4 安装pure-ftpd,执行,/configure时使用了--with-mysql参数,出现如下错误: checking whether you already have a ...

  8. python调用函数怎么错_在Python中从类调用函数时参数数目错误

    我试图用python编写一个遗传算法的实现.上面写着我用两个参数来调用它,而只有一个是允许的,但我肯定我不允许.在 以下是相关代码:class GA: def __init__(self, best, ...

  9. python成功安装cartopy之后,调用crs时却出现错误,如何解决

    # 导入所需的库 import cartopy import matplotlib as mpl import matplotlib.pyplot as plt import cartopy.crs ...

最新文章

  1. 真相了 | 敲代码时,程序员戴耳机究竟在听什么?
  2. 让你的spring-boot应用日志随心所欲--spring boot日志深入分析
  3. NYOJ 648 数字1的数量
  4. python email模块写邮件_python常用模块email----创建简单的文本邮件并发送
  5. 控制器局域网can总线
  6. TaskTResult 多线程 多参数 返回值
  7. Win7 64有点找不到MSVCP71.DLL和MSVCR71.dll
  8. Werkzeug Turorial
  9. module.exports与exports,export与export defa
  10. 【JOURNAL】Greeting via Connexion on Air in Lufthansa并一些祝福
  11. 【PBRT】圆盘均匀采样,python实现
  12. FPGA实现SPI 协议
  13. Android学习——四大核心组件(核心知识点整理)
  14. C++实例(十一)Excel表格操作
  15. server服务器系统2019安装,windowsserver 2019系统安装教程图文详解
  16. 记SUSE系统安装DM8开发版(单实例)
  17. html点击超链接启动邮件客户端创建电子邮件
  18. 服务器文件备份到本地方法,Windows服务器文件备份到本地的方法、Windows服务器数据备份方案...
  19. 华为2018软赛心得(西北36强)
  20. Quantopian教程源码解析及实战

热门文章

  1. Python-Opencv学习-实验-1:工具安装
  2. C语言 | 编程实现4
  3. matlab simulink 视频,使用 MATLAB 和 Simulink 让控制系统的开发更轻松
  4. html表单显示提示,html侧栏对应表单的提示显示
  5. _tcsnicmp_wcsnicmp
  6. php获取微信收款记录,微信公众号开发之微信支付代码记录的实现
  7. 为什么读博士的人越来越多?博士毕业难度不是越来越大吗?
  8. 温州大学《机器学习》课程课件(十一、降维)
  9. 【NLP】NLP哪个细分方向最具社会价值?
  10. 【数据竞赛】Kaggle实战之特征工程篇-20大文本特征(下)