1

i just started webdevelopment on ubuntu in core php and laravel Framework. I have installed php and all the dependencies but mysql is not working indiviually but its working inside lampp

so i began with giving the following command

mysql -u root -p

and the i get the following response(same for runing only 'mysql' and 'sudo mysql')

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

Also when i go to /var/run there is no folder with the name mysqld

cd /var/run/mysqld
bash: cd: /var/run/mysqld: No such file or directory

See this too

cd /var/run 
aq@DevilsBook:/var/run$ ls
acpid.pid     console-setup  dhclient-wlo1.pid  initctl      mount           rsyslogd.pid       sudo        user
acpid.socket  crond.pid      dmeventd-client    initramfs    network         sendsigs.omit.d    systemd     utmp
alsa          crond.reboot   dmeventd-server    lock         NetworkManager  shm                thermald    uuidd
apache2       cryptsetup     fsck               log          php             snapd-snap.socket  tmpfiles.d  wpa_supplicant
avahi-daemon  cups           gdm3               lvm          plymouth        snapd.socket       udev
blkid         dbus           gdm3.pid           lvmetad.pid  pppconfig       spice-vdagentd     udisks2

Other then That there is a folder named mysql and mysql-upgrade in /var/lib..

Then i tried the service mysql start command and it took so much time

sudo service mysql status
[sudo] password for aq: 
● mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; bad; vendor preset: enable
   Active: inactive (dead)

[1]+  Stopped                 sudo service mysql status

and run the same comand without sudo and i get

Job for mysql.service failed because the control process exited with error code.
See "systemctl status mysql.service" and "journalctl -xe" for details.

After that i see systemctl status mysql.service and the result was

● mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; bad; vendor preset: enable
   Active: failed (Result: exit-code) since Tue 2019-01-15 01:04:13 PKT; 28s ago
  Process: 3359 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exit

جنوری 15 01:04:13 DevilsBook systemd[1]: mysql.service: Service hold-off time ov
جنوری 15 01:04:13 DevilsBook systemd[1]: mysql.service: Scheduled restart job, r
جنوری 15 01:04:13 DevilsBook systemd[1]: Stopped MySQL Community Server.
جنوری 15 01:04:13 DevilsBook systemd[1]: mysql.service: Start request repeated t
جنوری 15 01:04:13 DevilsBook systemd[1]: mysql.service: Failed with result 'exit
جنوری 15 01:04:13 DevilsBook systemd[1]: Failed to start MySQL Community Server.
lines 1-11/11 (END)...skipping...
● mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; bad; vendor preset: enabled)
   Active: failed (Result: exit-code) since Tue 2019-01-15 01:04:13 PKT; 28s ago
  Process: 3359 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=1/FAILURE)

جنوری 15 01:04:13 DevilsBook systemd[1]: mysql.service: Service hold-off time over, scheduling restart.
جنوری 15 01:04:13 DevilsBook systemd[1]: mysql.service: Scheduled restart job, restart counter is at 5.
جنوری 15 01:04:13 DevilsBook systemd[1]: Stopped MySQL Community Server.
جنوری 15 01:04:13 DevilsBook systemd[1]: mysql.service: Start request repeated too quickly.
جنوری 15 01:04:13 DevilsBook systemd[1]: mysql.service: Failed with result 'exit-code'.
جنوری 15 01:04:13 DevilsBook systemd[1]: Failed to start MySQL Community Server.
~
~
~
~
~
~
~



[2]+  Stopped                 systemctl status mysql.service

At the end i ran journalctl -xe

جنوری 15 01:04:13 DevilsBook systemd[1]: mysql.service: Scheduled restart job, restart counter is at 5.
-- Subject: Automatic restarting of a unit has been scheduled
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- Automatic restarting of the unit mysql.service has been scheduled, as the result for
-- the configured Restart= setting for the unit.
جنوری 15 01:04:13 DevilsBook systemd[1]: Stopped MySQL Community Server.
-- Subject: Unit mysql.service has finished shutting down
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- Unit mysql.service has finished shutting down.
جنوری 15 01:04:13 DevilsBook systemd[1]: mysql.service: Start request repeated too quickly.
جنوری 15 01:04:13 DevilsBook systemd[1]: mysql.service: Failed with result 'exit-code'.
جنوری 15 01:04:13 DevilsBook systemd[1]: Failed to start MySQL Community Server.
-- Subject: Unit mysql.service has failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- Unit mysql.service has failed.
-- 
-- The result is RESULT.
جنوری 15 01:05:29 DevilsBook systemd[1]: Starting Cleanup of Temporary Directories...
-- Subject: Unit systemd-tmpfiles-clean.service has begun start-up
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- Unit systemd-tmpfiles-clean.service has begun starting up.
جنوری 15 01:05:30 DevilsBook systemd[1]: Started Cleanup of Temporary Directories.
-- Subject: Unit systemd-tmpfiles-clean.service has finished start-up
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- Unit systemd-tmpfiles-clean.service has finished starting up.
-- 
-- The start-up result is RESULT.

Even though mysql is working in lamp see the result of lampp runing sudo /opt/lampp/lampp start

aq@DevilsBook:~$ sudo /opt/lampp/lampp start
[sudo] password for aq: 
Starting XAMPP for Linux 7.2.13-0...
XAMPP: Starting Apache...fail.
XAMPP:  Another web server is already running.
XAMPP: Starting MySQL...ok.
XAMPP: Starting ProFTPD...ok.

How do i locate the folder and the package to eliminiate this issue ??

4
  • 2
    Are mysql / mysqld running at all ?
    – Soren A
    Jan 14, 2019 at 10:28
  • I dont think so, because when i login into mysql using terminal it give the first error message mentioned in the question
    – Syed Aqeel
    Jan 14, 2019 at 10:42
  • Just checked again and it says mysql ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
    – Syed Aqeel
    Jan 14, 2019 at 10:44
  • please edit your question with including the output of sudo service mysql status Jan 14, 2019 at 13:19

1 Answer 1

1

Answer from ->> https://www.youtube.com/watch?v=qr-t8ksYO78

go to my.cnf file, note that you will find multiple my.cnf file, i had to look at all of them to find this->

# The MySQL server
[mysqld]
user = mysql
port=3306
socket      = /opt/lampp/var/mysql/mysql.sock

Copy the path and write it like ->

mysql -u root -p --socket=/opt/lampp/var/mysql/mysql.sock 

Thanks

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .