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 is confusing because it does not say anything about the error. It is usually 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 directory).
  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: Linux, Web | 62 Comments »

62 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 !!!

  36. apekshit sharma Says:
    October 9th, 2010 at 4:29 pm

    It worked for me.Thanks!!

  37. links for 2010-10-27 | Edmonds Commerce Blog Says:
    October 27th, 2010 at 6:11 am

    [...] Solving “XAMPP: Couldn’t start MySQL!” at Compdigitec Labs (tags: xampp linux mysql problem solution) [...]

  38. carlos Says:
    October 28th, 2010 at 4:03 pm

    I had that problem an I SOLVED this way:

    I had this error:

    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.

    I coudn’t start mysql cause a mysql instanse was already running.

    In the terminal i did:
    apt-cache show mysql-server | grep Version
    and the terminal show me the mysql version
    so I did:
    sudo mysql
    and I got the prompt: mysql>

    That was I installed bacula backup which installed mysql

    So I used Synaptic Package Manager to uninstall bacula and mysql (severals packages of bacula and mysql)

    Thats all.

  39. xfcxv Says:
    November 1st, 2010 at 3:45 am

    It’s truly amazing how people STILL think that just chmod’ing everything to 777 is a fix-all for any issue. Complete and utter retard.

  40. Prib Says:
    November 11th, 2010 at 2:12 am

    thanks a lot
    it really worked

  41. amna Says:
    January 25th, 2011 at 5:27 am

    thanxs it worked

  42. Marco A Says:
    January 31st, 2011 at 5:54 am

    Thanks, it works!

  43. Swaroop Says:
    April 9th, 2011 at 4:23 am

    GUUYYSSS.. You all rock.. It worked like charm…

  44. xasx Says:
    April 30th, 2011 at 8:09 am

    Here is my 2 cents on how to get it to work. First, (this is assuming you are using Ubuntu 10.04 or higher and have nautilus-gksu installed.) Download current version of lampp from http://www.apachefriends.org/en/xampp-linux.html#374. After download go to places-computer-filesystem-and left click and open opt file as administrator. Drag the downloaded .tar lampp file into your opt file and extract it there. After file has been extracted, delete the .tar file. Now try to start lampp in a terminal by /opt/lampp/lampp start and now you should have no problem with permissions and mysql should work.

  45. xasx Says:
    April 30th, 2011 at 8:29 am

    Addendum: My above comment assumes you do not have lampp already installed on your computer. If you do have it installed, go to places-computer-filesystem- and open opt file as administrator using (Nautilus-gksu) and delete lampp folder. Then reboot computer and follow the rest of my instructions above from there. Remember, with apache and linux, often you must reboot computer for changes to take effect. Cheers!

  46. pr1s0ner Says:
    May 24th, 2011 at 5:30 pm

    Had the same problem, Can not start MySQL.
    Re-extracting files using tar -xvzf ***xampp_file*** instead of file roller fixed

  47. geomorillo Says:
    June 10th, 2011 at 3:09 am

    yeah tar -xvzf …… worked fine

  48. oharapedro Says:
    November 22nd, 2011 at 4:47 pm

    Cierto!!!!!!!!!!!
    Debemos usar el comando tar xvfz xampp-linux-1.7.7.tar.gz -C /opt para instalarlo ESA ES LA SOLUCION AL PROBLEMA (NO desde la ventana con el clic redecho, extraer)…. Me quebré la cabeza buscando una solución y fue tan simple :D

  49. ernemir Says:
    December 8th, 2011 at 9:37 pm

    I have to stop lammp and then start again. Doesn’t work with “sudo ./lamp restart” option

  50. Danish Satkut Says:
    December 30th, 2011 at 2:18 pm

    The problem is due to the fact that XAMPP package is installed for “nobody” user including the mysql and web server. So I am giving a short tutorial on how to make it work:

    1) After downloading your XAMPP package, do not use any GUI utility to extract it. please use the tar command with root permission (So that you can access you /opt directory)

    sudo tar -xzvf xampp-package-name -C /opt/

    Using the archival tools other than tar will result in problems.

    2) When you execute the above command, the directory is inaccessible to you as a normal user. To access this directory you will need root privileges with sudo command. This is a problem while developing. As a workaround, we will make htdocs accessible by your current user using the following commands.

    sudo chown -hR username /opt/lampp/htdocs
    sudo chmod -R 755 /opt/lampp/htdocs

    The above method wont show any warning as the lampp directory is not accessible to the world (except for htdocs). The above method works because mysql requires access to the /opt/lampp directory as “nobody”. When you perform chown for your user, nobody comes under others and 755 wont work and the only solution is 777 (which is bad).

  51. Danish Satkut Says:
    December 30th, 2011 at 3:04 pm

    For people who have changed the ownership from “nobody” to other users, change back the ownership to nobody for the entire package using:

    sudo chown -hR nobody /opt/lampp

    After executing the above command, make your htdocs accessible using the command listed in above post(point no. 2)

    This may result in a phpMyAdmin error. To tackle this problem, change the ownership of /opt/lampp/phpmyadmin and permissions accordingly:

    sudo chown -hR username /opt/lampp/phpmyadmin
    sudo chmod 755 /opt/lampp/phpmyadmin

    This will remove any phpmyadmin error.

  52. Nico Says:
    January 3rd, 2012 at 12:58 pm

    Thank you very much! It helped me a lot!!

  53. abudj Says:
    May 1st, 2012 at 6:56 am

    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.
    -------------------------------------

    wow,that works for me too….thanx Junianto….

  54. Ominous Says:
    May 12th, 2012 at 6:05 pm

    Thanks a lot. Worked at once.

  55. Puplu Says:
    May 13th, 2012 at 1:14 pm

    didn’t work :(

  56. Franz Says:
    June 30th, 2012 at 7:33 pm

    Thanks a lot, guy!!!
    This solved my problem!

  57. gema Says:
    August 19th, 2012 at 8:18 am

    thanks!!! it works !! :)

  58. mr nobody Says:
    August 23rd, 2012 at 4:55 am

    sudo chown nobody.root -R /opt/lampp/var/mysql/

    works and is better than setting all permissions to 777(read write execute for everyone)

    found here:
    http://www.apachefriends.org/f/viewtopic.php?f=17&t=49128

  59. Igor Says:
    October 17th, 2012 at 11:04 am

    Command ‘sudo tar -zxvf xampp-linux-1.8.1.tar.gz -C /opt’ solved this problem.

  60. Paulo Gomes Says:
    November 13th, 2012 at 9:08 am

    My resolution, that worked for me:
    http://adventux.blogspot.pt/2012/11/xampp-couldnt-start-mysql.html

    Cumprimentos,
    Paulo

  61. halms Says:
    April 26th, 2013 at 11:16 pm

    #58 is a more secure solution. thanks.

  62. Homepage Says:
    February 24th, 2014 at 11:27 am

    … [Trackback]

    [...] Informations on that Topic: compdigitec.com/labs/2009/05/30/solving-xampp-couldnt-start-mysql/ [...]

Comments