I have 3 MariaDB nodes. Want to configure cluster. Specified in gcomm:// in my.cnf ips of all members in cluster according to this.

And added ?pc.wait_prim=no at then of gcomm://ip1,ip2,ip3

Then mysqld process starts on each VM, but when i try to it connect with mysql -uroot -ppass in order to run

SET GLOBAL wsrep_provider_options="pc.bootstrap=1";

error pops:

Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2 "No such file or directory")

error.log of each process shows:

2018-02-01 15:13:23 140529975699392 [Note] WSREP: gcomm: connecting to group 'my_wsrep_cluster', peer ',,'
2018-02-01 15:13:23 140529975699392 [Note] WSREP: (71d7b5ed, 'tcp://') connection established to 71d7b5ed tcp://
2018-02-01 15:13:23 140529975699392 [Warning] WSREP: (71d7b5ed, 'tcp://') address 'tcp://' points to own listeddress, blacklisting
2018-02-01 15:13:23 140529975699392 [Note] WSREP: (71d7b5ed, 'tcp://') connection established to 6ac0d002 tcp://
2018-02-01 15:13:23 140529975699392 [Note] WSREP: (71d7b5ed, 'tcp://') turning message relay requesting on, nonlive peers:
2018-02-01 15:13:23 140529975699392 [Note] WSREP: (71d7b5ed, 'tcp://') connection established to 6bd1b1f9 tcp://
2018-02-01 15:13:23 140529975699392 [Note] WSREP: gcomm: connected
2018-02-01 15:13:23 140529975699392 [Note] WSREP: Changing maximum packet size to 64500, resulting msg size: 32636
2018-02-01 15:13:23 140529975699392 [Note] WSREP: Shifting CLOSED -> OPEN (TO: 0)
2018-02-01 15:13:23 140529975699392 [Note] WSREP: Opened channel 'my_wsrep_cluster'
2018-02-01 15:13:23 140529975699392 [Note] WSREP: Waiting for SST to complete.
2018-02-01 15:13:23 140529635424000 [Note] WSREP: declaring 6ac0d002 at tcp:// stable
2018-02-01 15:13:23 140529635424000 [Note] WSREP: declaring 6bd1b1f9 at tcp:// stable
2018-02-01 15:13:23 140529635424000 [Warning] WSREP: no nodes coming from prim view, prim not possible
2018-02-01 15:13:23 140529635424000 [Note] WSREP: view(view_id(NON_PRIM,6ac0d002,2) memb {
} joined {
} left {
} partitioned {
2018-02-01 15:13:23 140529627031296 [Note] WSREP: New COMPONENT: primary = no, bootstrap = no, my_idx = 2, memb_num = 3
2018-02-01 15:13:23 140529627031296 [Note] WSREP: Flow-control interval: [28, 28]
2018-02-01 15:13:23 140529627031296 [Note] WSREP: Trying to continue unpaused monitor
2018-02-01 15:13:23 140529627031296 [Note] WSREP: Received NON-PRIMARY.
2018-02-01 15:13:23 140529975253760 [Note] WSREP: New cluster view: global state: :-1, view# -1: non-Primary, number of nodes: 3, my ind protocol version -1
2018-02-01 15:13:23 140529975253760 [Note] WSREP: wsrep_notify_cmd is not defined, skipping notification.
2018-02-01 15:13:26 140529635424000 [Note] WSREP: (71d7b5ed, 'tcp://') connection to peer 71d7b5ed with addr tcp:// out, no messages seen in PT3S
2018-02-01 15:13:26 140529635424000 [Note] WSREP: (71d7b5ed, 'tcp://') turning message relay requesting off

Why does it happen and what's wrong?

  • Not related to the socket issue, but for bootstrapping you can use sudo service mysql bootstrap or sudo service mysql start --wsrep-new-cluster or with systemd: galera_new_cluster. (Though, not sure if perhaps it expects the mysqld process not to be running when issuing these commands.) – dbdemon Feb 2 '18 at 8:58

Check your config files /etc/my.cnf and /etc/my.cnf.d/server.cnf and look for the socket parameter. Make sure it's the same for client and server. A good place for the socket parameter is in the [client-server] section in /etc/my.cnf. The socket file is created by the MariaDB server when it starts up.

Note that there are other places where MariaDB config files could reside, and these could potentially override your settings in the two files mentioned above. For more details, see this page in the MariaDB KB.

Also note that you may be able to connect to MariaDB through TCP rather than through the socket. You can specify that you want to use TCP rather than the socket with mysql ... --protocol=TCP. If this is successful, you can then do SHOW VARIABLES LIKE 'socket'; to find out where the socket file really is (or should be). You can then connect with mysql ... --socket=/path/to/file.sock or edit the config files so that the client reads it correctly from there.

In some cases you may also be able to figure out what socket file location is used by listing the processes: ps -ef | grep mysql which could output something like

root     23900     1  0 13:27 ?        00:00:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --pid-file=/var/lib/mysql/vserv-03.pid
mysql    24402 23900  0 13:27 ?        00:00:50 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --wsrep_on=ON --wsrep_provider=/usr/lib64/galera/libgalera_smm.so --log-error=/var/lib/mysql/vserv-03.err --open-files-limit=65535 --pid-file=/var/lib/mysql/vserv-03.pid --socket=/var/lib/mysql/mysql.sock --wsrep_start_position=98b22222-aa16-1114-ba1a-886633c6b8eb:55133333

As you can see here (scroll right), it's using a socket at /var/lib/mysql/mysql.sock.

EDIT: A really good way of finding the location of the socket file is:

netstat -ln | grep mysql
unix  2      [ ACC ]     STREAM     LISTENING     22418    /var/lib/mysql/mysql.sock 
  • /var/run/mysqld/mysqld.sock is the same for client and server – rok Feb 1 '18 at 18:11
  • @user1264304 Are you able to log in over TCP instead of the socket? mysql -h -u root -ppass Then you can do show variables like 'socket'; It might be interesting to see if that agrees with your config files. – dbdemon Feb 1 '18 at 19:15
  • @user1264304 I've updated my answer with several more ideas. HTH. – dbdemon Feb 1 '18 at 21:29

Happened to me after a reboot... The socket file couldn't be found anywhere. In my case it should have been in: /var/run/mysqld/mysqld.sock

In my case, I fixed it by doing:

apt-get update
apt-get upgrade

After these steps, the socket appeared in mysqld directory and I could start mysql (mariaDB).

  • Thanks. I had the same problem and this fixed it. – Tom Dec 22 '19 at 7:45
  • It doesn't work that way. – metabuddy Apr 10 '20 at 10:00
  • @metabuddy could you explain what you mean? – user2677034 Apr 10 '20 at 15:36
  • I mean, I have the same situation where the socket file is missing. I ran the two update commands and rebooted but the file wasn't created. – metabuddy Apr 11 '20 at 17:14
  • @metabuddy make sure you also run apt-get upgrade, hopefully that will fix it. If not google update/upgrade not working as there could be issues with it not fully upgrading. – user2677034 Apr 12 '20 at 16:40

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.