Why mysql is not start in xampp?

The post will show to fix mysql problem on xampp. MySQL won’t start in my manager-osx application. It doesn’t throw me an in the application log. This is what it says:

Stopping all servers...
Stopping Apache Web Server...
/Applications/XAMPP/xamppfiles/apache2/scripts/ctl.sh : httpd stopped
Stopping ProFTPD...
Checking syntax of configuration file
/Applications/XAMPP/xamppfiles/proftpd/scripts/ctl.sh : proftpd stopped
Restarting all servers...
Starting MySQL Database...

Steps

1) Open terminal and type

sudo su

and then put in your password

2) Then type

ps aux | grep mysql

(just copy and paste this)

3) You will need to get the process id of mysql. There should be number near the top, something like 739 or 8827

4) Kill the process using

kill -9 {process id}

this should look something like this: kill -9 739

5) Restart MySQL in manager-osx

If any of the above don’t work, This should work:
sudo /Applications/XAMPP/xamppfiles/bin/mysql.server start

Find more at www.panayiotisgeorgiou.net

Why mysql is not start in xampp?

XAMPP is a great tool for web developers who need to run or test web applications locally on their own computer. Unfortunately, because it runs applications on the LAMP stack, conflicts can happen, causing certain applications on XAMPP to be unable to run.

In this article, we will be exploring what you can do if XAMPP’s MySQL service does not run on a macOS platform.

Are you looking at getting XAMPP MySQL to work on Windows instead? I’ve also wrote a guide for getting XAMPP Apache working on macOS. Do click on these aforementioned links if they are what you need instead.

  1. The problem
  2. Possible causes and fixes
    1. MySQL server conflict
    2. Killing existing MySQL processes using Terminal
    3. Changing MySQL’s port number
  3. Conclusion

1. The problem

If all of your XAMPP server programs are running except MySQL Database (like the below picture), then you are encouraged to read this article to find possible causes and solutions for your problem.

Why mysql is not start in xampp?
MySQL is not starting in XAMPP.

In your XAMPP control panel, you might see the following text, where MySQL database is getting stuck and just cannot start:

Stopping all servers...
Stopping Apache Web Server...
/Applications/XAMPP/xamppfiles/apache2/scripts/ctl.sh : httpd stopped
Stopping ProFTPD...
Checking syntax of configuration file
/Applications/XAMPP/xamppfiles/proftpd/scripts/ctl.sh : proftpd stopped
Restarting all servers...
Starting MySQL Database...

2. Possible causes and fixes

So, what might be causing the error described above?

a. MySQL server conflict

On your macOS, you might have multiple instances of MySQL servers running. This can be caused by other applications (for e.g. SQL Workbench) running their own instances of MySQL. To fix this issue, you need to stop the other instance of the MySQL server.

Here is how to do so:

  1. Go to Applications → Utilities → Activity Monitor.
  2. Select All Processes.
  3. Search for sql by using search box.
  4. You will see the mysqld process, double-click on it and press Quit.
  5. Once, done restart mysql in the manager-osx and it will run.

Why mysql is not start in xampp?
Removing existing mysqld processes using the Activity Monitor.

b. Killing existing MySQL processes using Terminal

Instead of using the Activity Monitor, you can also find and close existing mysqld processes using macOS’s Terminal.

Note: To run the following commands, you will need to be able to log in as a root user on your macOS. Here’s a guide (by Apple) on how to do this: https://support.apple.com/en-us/HT204012.

  1. Open Terminal, paste this command: sudo su; and type in your password.
  2. Then copy and insert this next command: ps aux | grep mysql. This will show you the processes with mysql in its name.
  3. After getting processes, you need to get the process ID of the processes named mysql. In my case, the process is named _mysql, so I need its process ID, which is 362 (highlighted below).
root              8006   0.0  0.0 408628336   1648 s000  S+   11:37AM   0:00.00 grep mysql
_mysql             362   0.0  0.0 35192992   3396   ??  Ss   Sun10PM   0:21.82 /usr/local/mysql/bin/mysqld --user=_mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --log-error=/usr/local/mysql/data/mysqld.local.err --pid-file=/usr/local/mysql/data/mysqld.local.pid --keyring-file-data=/usr/local/mysql/keyring/keyring --early-plugin-load=keyring_file=keyring_file.so
  1. Now, you need to kill this process, by using the following command: kill -9 {process id}, so for me the final command will be: kill -9 362.
  2. Restart MySQL in manager-osx and you will be good.

Tip: If you have multiple mysql processes and don’t know which want to stop, you can also stop ALL MySQL processes with sudo killall mysqld.

If you are unable to restart MySQL after, you can also try this command to directly start XAMPP’s MySQL server:

$ sudo /Application/XAMPP/xamppfiles/bin/mysql.server start

Article continues after the advertisement:


c. Changing MySQL port number

When starting XAMPP’s MySQL, if it says that it cannot connect to the port number, then changing it to a new one will help.

Why mysql is not start in xampp?
XAMPP cannot bind to port 3306.

To change port number, follow the instructions below.

Note: To change port number in the config file, you will need to be able to log in as a root user on your macOS. Here’s a guide (by Apple) on how to do this: https://support.apple.com/en-us/HT204012.

  1. Choose MySQL Database in manager-osx and click Configure.
  2. Change the port number to a new one, for example: 3307.

Why mysql is not start in xampp?
The Configure window for XAMPP’s MySQL service.

  1. Click Open Conf File and change the port number in the file.
  2. Close the config file and click OK.
  3. Relaunch manager-osx.

The highlighted portion of the config file below is where you change the port number:

my.cnf

# Example MySQL config file for medium systems.
#
# This is for a system with little memory (32M - 64M) where MySQL plays
# an important part, or systems up to 128M where MySQL is used together with
# other programs (such as a web server)
#
# You can copy this file to
# /etc/my.cnf to set global options,
# mysql-data-dir/my.cnf to set server-specific options (in this
# installation this directory is /Applications/XAMPP/xamppfiles/var/mysql) or
# ~/.my.cnf to set user-specific options.
#
# In this file, you can use all long options that a program supports.
# If you want to know which options a program supports, run the program
# with the "--help" option.

# The following options will be passed to all MySQL clients
[client]
#password	= your_password
port		=3306
socket		=/Applications/XAMPP/xamppfiles/var/mysql/mysql.sock

Now, you are good to go.

3. Conclusion

As with the other articles on the blog, we’d love if you leave a comment below, especially if you:

  • Find any errors in this article.
  • Find any XAMPP MySQL issues that are not described in this article.

Your comments will add on to the information that is already here, and help other future readers!

Post navigation

Why MySQL is not working in XAMPP?

The good news is that, if this does happen, there are three methods you can use to troubleshoot the issue: Run XAMPP using administrator privileges. Restore your database backup. Change your MySQL port.

How do I start MySQL in XAMPP?

Setup mySql and install some textbook databases on your machine.
In phpmyadmin, click the Users tab at the top..
Find the row that has User root and Host 127.0.0.1..
Click Edit Privileges..
Click Change password..
Enter the password twice (write it down somewhere if you're not sure you can remember it).
Click the Go button..

Why MySQL service is not starting?

Even with correct ownership, MySQL might fail to start up if there is other security software running on your system that manages application access to various parts of the file system. In this case, reconfigure that software to enable mysqld to access the directories it uses during normal operation.

Why MySQL is not starting in XAMPP in Mac?

a. On your macOS, you might have multiple instances of MySQL servers running. This can be caused by other applications (for e.g. SQL Workbench) running their own instances of MySQL. To fix this issue, you need to stop the other instance of the MySQL server.

Why Apache XAMPP Cannot start?

This may be due to a blocked port, missing dependencies, improper privileges, a crash, or a shutdown by another method. Check the "/xampp/apache/logs/error. log" file and the Windows Event Viewer for more clues.

How do I fix MySQL not working?

How to fix common problems with MySQL databases.
Check that the service is running. If your website cannot connect to your database, it is possible the service is simply not listening. ... .
Check the configuration. ... .
Check the error logs. ... .
Ask for help..