Compdigitec Labs

« | Home | »

Solving “XAMPP: Couldn’t start MySQL!”

By admin | May 30, 2009

XAMPP for Linux is a convenient package for installing the AMPP stack (Apache, MySQL, PHP, Perl) of web server software, but it also has its own share of problems. One such error is the generic and uninformative error of “XAMPP: Couldn’t start MySQL!“. This can confuse users because it does not say anything about there error. This error is caused by permission errors because it is not able to write to a directory. Here is how to fix it.

  1. Open a terminal.
  2. Once the terminal has loaded, type “sudo chown -hR root /opt/lampp“. (Note: replace /opt/lampp with the XAMPP install director(y.
  3. (Update from comment #7, untested) Type “sudo chmod -R 777 /opt/lampp“.
  4. Restart XAMPP with “sudo /opt/lampp/lampp restart“.
  5. Exit the terminal (right-hand corner X or type exit).

Alternate solution for those who could not get the above working:

  1. Re-download the LAMPP package from http://www.apachefriends.org/. (wget http://downloads.sourceforge.net/sourceforge/xampp/xampp-linux-1.7.1.tar.gz -O /tmp/xampp-linux-1.7.1.tar.gz)
  2. Navigate to /opt/lampp/htdocs (or where-ever you store your documents) and back it up to another location. (mkdir /tmp/htdocs followed by cp -r /opt/lampp/htdocs/*/tmp/htdocs/)
  3. (optional) Also back up the configuration directory and the phpmyadmin configuration (mkdir /tmp/etc followed by cp -r /opt/lampp/etc/*/tmp/etc/ followed by cp /opt/lampp/phpmyadmin/config.inc.php /tmp/)
  4. Delete the entire LAMPP tree (sudo rm -rf /opt/lampp)
  5. Re-extract the LAMPP tree from root (tar xvfz /tmp/xampp-linux-1.7.1.tar.gz -C /opt)
  6. Restore htdocs folder to /opt/lampp (sudo cp -r /tmp/htdocs/* /opt/lampp/htdocs/)
  7. (optional) Restore configuration folder and phpmyadmin config (sudo cp -r /tmp/etc/* /opt/lampp/etc/ followed by sudo cp /tmp/config.inc.php /opt/lampp/phpmyadmin/config.inc.php)

If you found this article helpful or interesting, please help Compdigitec spread the word. Don’t forget to subscribe to Compdigitec Labs for more useful and interesting articles!

Topics: HTTP (Internet), Linux | 35 Comments »

35 Responses to “Solving “XAMPP: Couldn’t start MySQL!””

  1. alper Says:
    June 15th, 2009 at 5:19 pm

    did not work.

  2. admin Says:
    June 18th, 2009 at 7:58 pm

    Please be more specific – what version of XAMPP for Linux were you using? If not the latest, did you upgrade? If it did not work, what is the error returned?

  3. erros Says:
    June 24th, 2009 at 4:16 am

    ya, it didn’t work. still show could’t start Mysql !

  4. gleb Says:
    June 27th, 2009 at 9:52 am

    Didn’t work for me either. I’m using the latest issue of Xammp on Ubuntu Jaunty

    ?@?-laptop:~$ sudo chown -hR root /opt/lampp
    ?@?-laptop:~$ sudo /opt/lampp/lampp start
    Starting XAMPP for Linux 1.7.1…
    XAMPP: Starting Apache with SSL (and PHP5)…
    XAMPP: Starting MySQL…
    XAMPP: Couldn’t start MySQL!
    XAMPP: Starting ProFTPD…
    XAMPP for Linux started.

  5. Antonio Says:
    June 27th, 2009 at 12:04 pm

    I’m also having the same problems on Ubuntu Jaunty. The solution didn’t work for me unfortunately

  6. Paul Says:
    July 7th, 2009 at 10:43 pm

    I had same problem. Was becuase I didn’t install as root. I removed lampp directory and reinstalled as root and this fixed the problem.

  7. Tony Pirog Says:
    July 22nd, 2009 at 9:32 am

    BETTER SOLUTION!!!!

    Don’t do the CHOWN. It doesn’t work.

    Instead,

    1. Enter “Sudo Nautilus” which brings up a folder window.

    2. Navigate to /opt

    3. Right click on the lampp folder and select the permissions tab.

    4. Enable “Create and Delete Files” Folder Access on all three levels and also “Read and Write” File Access.

    5. Click on “Apply Permissions to Enclosed Files”.

    6. Close the properties dialog.

    You are now ready to restart Xampp per instructions above.

    Good luck.

  8. Tepi Says:
    July 23rd, 2009 at 3:38 pm

    Thanks, apparently worked for me!!!

  9. czer Says:
    August 15th, 2009 at 12:25 pm

    I did work! after trying chown and chmod,
    It’s because chmod changes write permissions to MySQL files and folders. Which enables you to run MySQL. thanks for the solution.

  10. foetus Says:
    August 23rd, 2009 at 3:05 pm

    great article!!!!… ;)

  11. Kasun Says:
    September 12th, 2009 at 4:05 am

    after doing chown and chmod you will get a warning as,
    Warning: World-writable config file ‘/opt/lampp/etc/my.cnf’ is ignored

    If you want to get rid of this,
    1. Open a terminal and change the directory to /opt/lampp/etc
    2. Type and run “sudo chmod 755 my.cnf”

    Then start xampp again. You won’t get the warning message again.

    -Cheers-

  12. Siwalaze Says:
    September 22nd, 2009 at 3:04 am

    I started lampp in ubuntu 9.04 and i found the following errors:
    XAMPP: Starting MySQL…
    Warning: World-writable config file ‘/opt/lampp/etc/my.cnf’ is ignored
    Warning: World-writable config file ‘/opt/lampp/etc/my.cnf’ is ignored

    What could be the possible error i made?

  13. admin Says:
    September 27th, 2009 at 3:47 pm

    @Siwalaze:

    ” 1. Open a terminal and change the directory to /opt/lampp/etc
    2. Type and run
    sudo chmod 755 my.cnf

  14. Roman Says:
    October 23rd, 2009 at 8:23 pm

    This solution is not relevant, I found out that I get the same error when I used the packager utility instead of the command line “tar -zxvf”, apparently, the latter maintains the required permission on the files (or maybe since I am using sudo when I am unpacking the files into /op/)

    Anyway, if you just use the tar -zxvf file.tgz -C /opt/, you will not have this issue! (tested it!)

  15. Siwalaze Says:
    November 6th, 2009 at 1:47 pm

    I have done this

    1. Open a terminal and change the directory to /opt/lampp/etc
    2. Type and run
    sudo chmod 755 my.cnf


    but still i get the error
    “Wrong permissions on configuration file, should not be world writable!”
    I wonder why all this errors occur!!!!!!!!!!!!!

  16. Cara Menginstal MySql di Linux « nisa wordpress Says:
    November 8th, 2009 at 3:01 am

    [...] http://www.compdigitec.com [...]

  17. theghost Says:
    December 6th, 2009 at 6:21 am

    thank :)
    it worked

    at Siwalaze:
    click alt+f2 and write gksu nautilus
    then go to /opt/lampp/phpmyadmin/
    and click right click at config.inc.php then properties

    and change the permissions to read-only

  18. Siyam Junianto Says:
    December 10th, 2009 at 5:31 am

    i just chmod mysql folder :
    sudo chmod -R 777 /opt/lampp/var/mysql

    and it’s worked!

    thx.

  19. Joshua Says:
    December 21st, 2009 at 4:55 am

    Thanks to you all.It worked for me but i get some funny warning msg (Warning: World-writable config file ‘/opt/lampp/etc/my.cnf’ is ignored
    Warning: World-writable config file ‘/opt/lampp/etc/my.cnf’ is ignored)

    Does anyone have an idea of what this could be.

  20. Scoup Says:
    December 31st, 2009 at 9:10 am

    I reinstaled with root and now is working.

  21. Iron Says:
    January 12th, 2010 at 3:25 pm

    Worked for me.

  22. James Revillini Says:
    January 27th, 2010 at 11:32 am

    niiiiiiiiiiiiiiiiiiiice. the chmod command in the first set of steps took care of it.

  23. gastón Says:
    February 22nd, 2010 at 11:46 pm

    worked perfectly!!

    thanks :D

  24. Nigel Says:
    March 20th, 2010 at 7:41 am

    Solved a complex issue. Thanks.

  25. Setiawan Says:
    March 26th, 2010 at 4:26 am

    It worked for me.

    Thanks a lot for the help

  26. Caleb Says:
    April 17th, 2010 at 4:30 pm

    If you guys do this to a production server, I would not recommend changing permissions to 777, and let the world have R/W access. I realized this then changed everything back to 755 (still fixed the MySQL not being able to start issue). Cheers for the fix!

  27. Caleb Says:
    April 17th, 2010 at 4:39 pm

    Also, changing the owner to ‘root’ will cause errors with a lot of CMS scripts and who knows what else that is out there, the user for the Debian distro version of XAMPP is ‘nobody’.

  28. Caleb Says:
    April 17th, 2010 at 4:43 pm

    SO:

    sudo chown -hR nobody /opt/lampp

    -and-

    sudo chmod -R 755 /opt/lampp

    Should do the same fix, while keeping security somewhat tight, and still allowing scripts to update necessary files and do other stuff that requires write access by the script itself.

    Cheers!

  29. xuanduc Says:
    May 24th, 2010 at 3:24 am

    Hi, I’ve just changed
    sudo chmod 755 /opt/lampp/phpmyadmin/config.inc.php
    then it’s worked

  30. luobo25 Says:
    May 25th, 2010 at 8:00 am

    It wored for me. Thanks :)

  31. Porfirio Says:
    June 1st, 2010 at 4:43 am

    Hi, thanks for the help it worked for me this way:

    1:
    Since I started mysql before installing xampp:

    sudo /etc/init.d/mysql stop

    2:
    All in the first post

    3:
    =================================
    Kasum post:
    If you want to get rid of this,
    1. Open a terminal and change the directory to /opt/lampp/etc
    2. Type and run “sudo chmod 755 my.cnf”
    =================================
    4:
    sudo chmod a-w /opt/lampp/phpmyadmin/config.inc.php

    from http://www.bugbase.com.ar/-post-111-phpmyadmin_wrong_permissions_on_configuration_file_should_not_be_world_writable.html

    And that’s it..

  32. Starqs Says:
    August 18th, 2010 at 3:04 am

    I had the same error. “XAMPP: Couldn’t start MySQL!” and, after trying the huge amount of solutions found on the net I realized that the *real* solution was under my nose, more accurate, inside the /opt/lampp/var/mysql/$HOSTNAME.err file. I read “Do you already have another mysqld server running on port: 3306 ?”. After a $ps ef | grep mysql I saw the ligth. A simple killing of the processes involved solved the problem. Hope it helps.

  33. salem Says:
    August 25th, 2010 at 4:15 pm

    Still not working
    i got the same error ..put it solve Mysql issue the i got when i trying to solve PhpmyAdmin issue
    any way that what i got

    Stopping XAMPP for Linux 1.7.3a…
    XAMPP: Stopping Apache with SSL…
    XAMPP: XAMPP-MySQL is not running.
    XAMPP: Stopping ProFTPD…
    XAMPP stopped.
    Starting XAMPP for Linux 1.7.3a…
    XAMPP: Starting Apache with SSL (and PHP5)…
    XAMPP: Starting MySQL…
    Warning: World-writable config file ‘/opt/lampp/etc/my.cnf’ is ignored
    Warning: World-writable config file ‘/opt/lampp/etc/my.cnf’ is ignored
    XAMPP: Starting ProFTPD…
    XAMPP for Linux started.

  34. Adam Says:
    August 26th, 2010 at 5:20 pm

    Worked!!! Thanks!

  35. Naveenparth Says:
    August 28th, 2010 at 2:02 am

    Hey Roman – you are right

    By using ‘tar -zxvf’ command instead of package extracting service, this problem will not be faced.

    It rocks !!!

Comments