XAMPP中Apache和Mysql啓動失敗問題總結

XAMPP中Apache和Mysql啓動失敗問題總結

一、Apache啓動失敗

xampp啓動時顯示的錯誤爲:

9:52:41  [Apache]  Attempting to start Apache app...

9:52:41  [Apache]  Status change detected: running
9:52:42  [Apache] Status change detected: stopped
9:52:42  [Apache] Error: Apache shutdown unexpectedly.
9:52:42  [Apache] This may be due to a blocked port, missing dependencies, 
9:52:42  [Apache] improper privileges, a crash, or a shutdown by another method.
9:52:42  [Apache] Check the "/xampp/apache/logs/error.log" file

9:52:42  [Apache]  and the Windows Event Viewer for more clues

這個問題比較常見, 通常是80、443端口被佔用

cmd 通過運行apache/bin/httpd.exe 打印如下log: 

(OS 10048)通常每個套接字地址(協議/網絡地址/端口)只允許使用一次。 : make_sock: could not bind to address 0.0.0.0:443 
或者後面是80端口被佔用

(OS 10048)通常每個套接字地址(協議/網絡地址/端口)只允許使用一次。 : make_sock: could not bind to address 0.0.0.0:80  或[ : : ]:80 

1、最快的處理方法就是修改端口號:

1.1、443端口被佔用,apache無法監聽443端口,該如何解決呢? 

在/xampp/apache/conf/extra/httpd-ssl.conf 

把Listen 443 修改爲 444(可自定義)


1.2、80端口被佔用,apache無法監聽80端口,該如何解決呢? 

在/xampp/apache/conf/extra/httpd.conf 

把Listen 80 修改爲 88 (可自定義)

如果配置了vhosts的話請把httpd-vhosts.conf 中端口改爲88(同上端口號)

2、最直接的方法是關閉佔用80、443端口的進程: 

1. 通過cmd中netstat -ano 看看本機80、 443端口被佔用沒               ----- --這裏 可能會被其他程序佔用如iis、虛擬機等
2.通過cmd中打印tasklist,查找佔用80、443端口的進程名稱。 
3.taskkill /pid 端口號 殺掉此進程名稱,XAMPP重啓apache即可。

綜上所述第一種方法推薦使用,第二種每次啓動都或多或少的再次遇到。

二、MySQL啓動失敗

在使用數據庫後,退出數據庫,再次登錄,可能會產生下面一種情況

XAMPP – MySQL shutdown unexpectedly
14:39:04  [mysql]         Status change detected: running
14:39:05  [mysql]         Status change detected: stopped
14:39:05  [mysql]         Error: MySQL shutdown unexpectedly.
14:39:05  [mysql]         This may be due to a blocked port, missing dependencies,
14:39:05  [mysql]         improper privileges, a crash, or a shutdown by another method.
14:39:05  [mysql]         Press the Logs button to view error logs and check
14:39:05  [mysql]         the Windows Event Viewer for more clues
14:39:05  [mysql]         If you need more help, copy and post this

14:39:05  [mysql]         entire log window on the forums

 (大體的意思就是意外停止  具體記不太清了  等有機會截圖上來)

我的解決方法有三種:

1、把xampp\mysql\data下的ibdata1文件刪掉

  • 找到本地安裝存放xampp的文件夾,點擊打開文件夾;
  • 找到Mysql文件夾,點擊打開;
  • 找到data文件夾,點擊打開;
  • 找到 ibdata1 這個文件,並刪除它;
  • 重新啓用MYSQL

但是這個文件夾是用來存儲真實的數據庫數據的,如果刪掉就相當於刪掉了數據庫,而且每次對數據庫進行操作後,該表會重新生成。

所以嘗試將該文件轉移到另一個位置

而該文件的生成路徑是由配置文件中設置的

最終,按下面方法解決了

在mysql的配置文件C:\xampp\mysql\bin\my.ini中,將以下幾行改掉:

innodb_data_home_dir = "/xampp/mysql/data"
innodb_log_group_home_dir = "/xampp/mysql/data"
#innodb_log_arch_dir = "/xampp/mysql/data"

可以改爲:

innodb_data_home_dir = "/xampp/mysql/data/sqldata"
innodb_log_group_home_dir = "/xampp/mysql/data/sqldata"
#innodb_log_arch_dir = "/xampp/mysql/data/sqldata"

  在此之前,要現在/xmapp/mysql/data下建立一個新文件夾sqldata

2、在mysql/bin/my.ini 文件 添加一段代碼:

  [mysqld]
 innodb_force_recovery = 4

然後重啓MySQL服務

3、用管理員啓動MySQL服務

用管理員啓動命令行,進入mysql的bin目錄,輸入mysqld --install,回車,

提示:Service successfully installed,

表示安裝MySQL服務成功。

命令行窗口輸入:net start mysql ,可以正常啓動。

好了,就這麼多了,mysql服務啓動以後就沒什麼問題了。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章