第二次启用httpd24调用mysql时出现的错误
問題來了,到瀏覽器輸入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时出现的错误的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: js正则表达式test()和exec()
- 下一篇: mysql 子查询优化一例