日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

第二次启用httpd24调用mysql时出现的错误

發布時間:2025/1/21 数据库 71 豆豆
生活随笔 收集整理的這篇文章主要介紹了 第二次启用httpd24调用mysql时出现的错误 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
#?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时出现的错误的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。