0

The client doesn't in work running Ubuntu.

mysql -u root -p gives

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

Messed up the mysql-community installation, first did

tar --strip-components=1 -XJf /usr/home/lasse/mysql-8.0.18-linux-glibc2.12-x86_64.tar.xz

at /usr/local

Couldn't start mysqld so I abandoned it and downloaded the Debian bundle.

Installed the client and the server and several other dependent packages with sudo dpkg -i, and finally got mysqld up and running somehow but I cannot connect to it. Reading ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) gives that I should have a /etc/my.cnf, so I copied it from /etc/mysql/my.cnf What should I try next?

Romeo Ninov
  • 6,538
  • 1
  • 22
  • 31
Lasse Karagiannis
  • 471
  • 2
  • 6
  • 12

1 Answers1

0

In /etc/my.cnf you should have:

[client]
socket=/var/lib/mysql/mysql.sock
[mysqld]
socket=/var/lib/mysql/mysql.sock

(or other, but the same for both sections file) or have in the file

[client]
port = 3306
[mysqld]
port = 3306

This will make client to connect to server via socket (first case) or via TCP port

Romeo Ninov
  • 6,538
  • 1
  • 22
  • 31
  • Added both of your suggestions but it still doesn't work. – Lasse Karagiannis Dec 23 '19 at 15:59
  • did you restart the server? – Romeo Ninov Dec 23 '19 at 16:00
  • Must have really messed up. Restarted but got ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) – Lasse Karagiannis Dec 23 '19 at 16:04
  • Do you have this path? `/var/lib/mysql/` Is it owned by mysql user? – Romeo Ninov Dec 23 '19 at 16:05
  • I have it root@Lenovo:/var/lib/mysql# ls -la total 168020 drwxr-x--- 6 mysql mysql 4096 dec 23 17:02 . drwxr-xr-x 68 root root 4096 dec 23 15:03 .. -rw-r----- 1 mysql mysql 56 dec 23 15:03 auto.cnf shorting the list drwxr-x--- 2 mysql mysql 4096 dec 23 17:02 '#innodb_temp' drwxr-x--- 2 mysql mysql 4096 dec 23 15:03 mysql -rw-r----- 1 mysql mysql 25165824 dec 23 17:02 mysql.ibd – Lasse Karagiannis Dec 23 '19 at 16:11
  • Check if you have other directives in config and mysqld sections which can mess the things. – Romeo Ninov Dec 23 '19 at 16:15
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/204744/discussion-between-lasse-karagiannis-and-romeo-ninov). – Lasse Karagiannis Dec 23 '19 at 16:21