I installed XAMPP on Ubuntu 18.04, ran /opt/lampp/lampp start and all the services started successfully. However, when I try to run mysql -u root -p I get this error:

"ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)"

If I try to run sudo service mysql start, I get this error: "Failed to start mysql.service: Unit mysql.service not found."

I have uninstalled and reinstalled XAMPP. I can still access phpMyAdmin and display the index.html on the browser. I've also read several other posts with similar titles, but none of the proposed solutions has fixed my issue.


If you want to run the XAMPP`s mysql you should run:

/opt/xampp/bin/mysql instead of mysql

The error may be because you already have mysql package installed via apt

NB: XAMPP includes MariaDB not MySQL

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.