1

I want to run a website from my computer. I use XAMPP on a Kali Linux.

I installed MySQL server with the command: apt-get install mysql-server

After it was successfully installed, I entered the command mysql_secure_installation

It prompted me to login to MySQL, but it repeatedly gave the error

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

screenshot

I tried my password several times, with no changes just to check if I have typed it wrong the first time.

Can anyone tell me how to fix this? I am following a tutorial from this site.

  • 1
    I think you are mixing up things. I could swear Xampp brings his own MySQL server, but then again I usually do not recommend it, as you can build you LAMP stack with native packages in Linux. – Rui F Ribeiro Apr 3 '16 at 7:58
  • 1
    posting a link to an externally hosted screenshot is even worse than posting a screenshot. don't do either. copy and paste the text from your console or terminal session. – cas Apr 4 '16 at 2:18
  • @roaima: Your edit broke the screenshot! (I fixed it.) – G-Man Says 'Reinstate Monica' Apr 7 '16 at 3:39
  • @XIII: You say "I tried my password several times, ... just to check if I have typed it wrong the first time."  What are you saying?  Are you typing your root login password?  MySQL maintains its own passwords, independent of the operating system; when you install MySQL, it sets up a root account with a blank password.  Unless you set a MySQL root password and you aren't telling us about it, you should just be typing <Enter> for the password.  That said, I agree with digitaladdictions: the "Can't connect" error message makes it look like the server is not running. – G-Man Says 'Reinstate Monica' Apr 7 '16 at 3:46
0

The error about not being able to connect to the socket suggests that the server is not running.

The following command will start the MySQL server.

service mysql start

Providing that works and you wish for MySQL to automatically start with the server use this command.

update-rc.d mysql enable

  • i try it. worked. but I type mysql_secure_installation again. It still don't get successfully. but error different. can you help me more? – XIII Apr 3 '16 at 9:29
  • Does "service mysql status" show that MySQL is running? Is their a mysqld.sock file in /var/run/mysqld/? I do not know anything about Xampp. There might be some conflicts if it came with its own version of MySQL and you also installed it separately from Xampp. – digitaladdictions Apr 3 '16 at 9:45
  • @XIII: Please don't post comments that say "error different".  Edit your question to describe what you have tried, and give the exact error message — preferably as text (instead of a screenshot). – G-Man Says 'Reinstate Monica' Apr 7 '16 at 3:51
  • I still hold my opinion the problem is xampp bringing a copy of MySQL and the OP having two different MySQL servers installed. – Rui F Ribeiro Feb 10 '18 at 10:55
0

XAMPP brings it´s own copy of MySQL. Installing the official package only means you now have two MySQL servers instances installed.

So what can happen, depending on configurations is:

  • one of the instances of MySQL is not starting/not configured correctly/not with full setup completed;
  • OR both are running, and you won't be able to talk with one of them;
  • OR you are talking with the wrong instance without realising it.

For now, I do recommend deleting the official package and restarting the MySQL from XAMPP as a quick fix.

As recommendations for a near future:

There are several choices for a PHP framework installation, and two choices concerning this particular question:

  1. using the official distribution packages of Apache, MariaDB/MySQL, PHP and Perl;
  2. installing XAMPP.

I recommend the former approach, of using the official packages of the distribution instead of XAMPP for the following reasons:

  • it is more standard (even for asking help here);
  • the file locations are more standard;
  • it is supported by the distribution;
  • it also benefits from more regular security updates of the OS;
  • on top of that it also gives less problems when upgrading either the MySQL version or the distribution version.

IMO XAMPP is better suited for people running Windows, for people running Linux it is more difficult to maintain updated and is not standard.

  • As an anecdotal tale, it did not take me long to migrate a XAMPP server I inherited for a new one using official packages. Easier than dealing with XAMPP. – Rui F Ribeiro Feb 10 '18 at 11:15

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.