How To Connect To MySQL Server After Install XAMPP On Mac OS

XAMPP is a software package which is a bundle of apache, mysql and ftp package. You always need to use it when you develop php + mysql application. It is easy to use on Windows, but when i use it on Mac OS, i meet some errors, this article will tell you how to install, start, stop XAMPP on Mac OS and fix all these errors.

1. How To Install, Start, Stop XAMPP On Mac OS.

First you should download the XAMPP installer for Mac OS. If you find the XAMPP official website can not be accessed, you can search keyword XAMPP in and download it there.

After download XAMPP mac os version, double click it to install it. After install, you can start it by click XAMPP icon in finder /Applications folder.

xampp in mac os applications folder

After click XAMPP icon, it will display below popup window. Click Start button to start both apache, mysql and ftp server as service.  Click Stop button to stop it.

click xampp start button to start apache mysql ftp server

After click Start button, you can see the server status and server IP Address at the top area of above window. Please remember the ip address. The server is running in an embed linux server, and the server ip is just the ip address.

Click the Go to Application button will show you the XAMPP dashboard in a popup web browser. Click the Open Terminal button will open a terminal and login to the embedded linux server with root user.

after start xampp, it will display server service and server ip address at window top area

If you want to know where the XAMPP files is installed, you can click the Volumes tab in above XAMPP manager window, then click the Mount button to mount the /opt/lampp directory on XAMPP linux server to local Mac OS, then click Explore button to open XAMPP install folder in popup local Mac finder window. You can copy your WordPress website source files into the htdocs folder to browse it in web browser.

mount xampp install folder in xampp manager window

2.How To Fix Can Not Access XAMPP Apache Dashboard Use Localhost Error.

In past, after start XAMPP, we usually access it’s dashboard web page use url http://localhost/dashboard/. But when i use this url, it can not open the page. This is because we are not running web browser in XAMPP embed linux server, we access it in Mac OS.

To access XAMPP apache dashboard, you should use the XAMPP embed Linux server’s ip to replace localhost like this,

3.How To Fix Can Not Connect To MySQL Server With Root User Error.

To manage the XAMPP MySQL server, you can use MySQL workbench. If you use root user with empty password ( the root user’s password is empty by default ), it will popup error message Failed to Connect to MySQL at with user root. This error is because the MySQL server’s Hostname is wrong, the MySQL server Hostname should be the running XAMPP server’s ip address, which is in this example.

But when you use XAMPP linux server’s ip as the Hostname and use root user with empty password, it will popup another error dialog which said Failed to Connect to MySQL at with user root, Access denied for user ‘root’@’’ (using password: NO). You can read article How To Resolve Access Denied For User ‘root’@’localhost’ (using Password: Yes) When Connect MySQL Database to fix this, but we had also list the short steps about how to fix it as below.

connect to xampp mysql server failed with root user

To fix this error, you should click the Open Terminal button in XAMPP manager window, then follow below steps to resolve it.

  1. Connect to mysql server in command line with root user, the default root user’s password is empty.
    [email protected]:/# mysql -u root -p
    Enter password: 
    Welcome to the MariaDB monitor.  Commands end with ; or \g.
    Your MariaDB connection id is 9
    Server version: 10.3.16-MariaDB Source distribution
    Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
    MariaDB [(none)]> 
  2. Select all host and user name from mysql.user table use select sql command like below. We can see that the root user can only connect to the embedded mysql server on localhost, and the localhost is the XAMPP linux server, but MySQL workbench is running on the Mac OS. So you should grant root user access permission to the MySQL server from any machine with ‘%’ as the host value.
    MariaDB [(none)]> select host, user from mysql.user;
    | host      | user  |
    | | root  |
    | ::1       | root  |
    | localhost |       |
    | localhost | pma   |
    | localhost | root  |
    6 rows in set (0.001 sec)
  3. But generally, allow root user access MySQL server from any machine is not safety, so we had better create another MySQL user account and make it to connect to MySQL server from any machine remotely.
  4. Create a new MySQL server user account with provided username and password use MySQL CREATE USER command. Please note @’%’ means jerry can connect to MySQL server remotely from any machine.
    CREATE USER 'jerry'@'%' IDENTIFIED BY 'jerry';
  5. Grant all privileges to user account ‘jerry’@’%’.
  6. Now use above newly created user account to connect to MySQL server. Please note the Hostname should be the MySQL server ip address ( displayed in XAMPP manager window top area ).connect to xampp mysql server use xampp server ip
  7. When you connect to MySQL server successfully, you will get below successful message dialog.
    connect to xampp mysql server successfully from mysql workbench
0 0 votes
Article Rating
Notify of

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Oldest Most Voted
Inline Feedbacks
View all comments
Ned Odo
Ned Odo

After 2days of searching everywhere on the internet, you saved me. Thanks you.

Fahim Al Mahmud Ashik
Fahim Al Mahmud Ashik

I usually don’t reply to help post…But you’ve saved couple of days of mine…thank you so much ?


after 24 hours of search, I was able to stumble upon your blog thanks so much, it save me so much headache. I can rest a little now.. Thanks.

Chris M
Chris M

I never reply to these things…but i’ve been banging my head trying to figure this out all day. I had everything except for the part where you set % as the host value. Thanks so much man I can go to sleep now


thank you so much my friend


Thank you so much my friend. I found it in 3 days. OMG!! thanks for your help.


This is the perfect solution to my problem. I had installed xampp on mac, and was unable to connect to mysql database through laravel. Your solution made sense and it actually worked. Thanks a ton!

Would love your thoughts, please comment.x