Score:0

Run mysql in terminal without argument giving socket error

be flag

When I type in mysql into terminal I got the following error:

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

But if run mysql with some arguments like below:

mysql -h 127.0.0.1 -P 3306 -u root -p

It asked me the mysql password that is already defined in /etc/my.cnf . So I pasted the same password and I got connected to the database terminal like this:

Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 4
Server version: 10.6.4-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

In my /etc/my.cnf I have the following content:

[mysqld]
bind-address=127.0.0.1
port=3360
max_allowed_packet=64M
local-infile=0
innodb_file_per_table

[client]
user=root
password=MYSQLPASSWORDHERE
socket=/usr/local/mysql/data/mysql.sock

The question is, since I already have predefined root password, port and bind-address in /etc/my.cnf, why does it still show error about socket if I run mysql command without any arguments

My aim is to run mysql command in terminal without any argument and it will present me the mysql terminal

Score:0
be flag

I found the solution to this problem. I had install Debian mailutils package before like this:

apt install mailutils

and it will include the following package:

The following additional packages will be installed:
  gsasl-common guile-2.2-libs libgc1 libgsasl7 libidn11 libmailutils7 libmariadb3 libntlm0
  mailutils-common mariadb-common mysql-common

I think this is due to conflict of mariadb installation, So when I remove this mailutils package from Debian I don't have that error anymore. So I can simply run mysql in terminal without socket error.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.