Score:0

Can't connect to mysql after managing systemctl (Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock')

cn flag

I needed to run a program (just a compiled c++ program, not script, i.e., like /var/programname) on startup on CentOS 7.

I followed this guide https://www.howtogeek.com/687970/how-to-run-a-linux-program-at-startup-with-systemd/

Rebooted via reboot command, checked if my program is running via ps aux, it is.

But now, I can't connect to mysql database (maybe there are other problems). I have phpMyAdmin, it running through browser, but when I try to login it throws:

mysqli_real_connect(): (HY000/2002): No such file or directory

Running mysql -u root -p command, after input root password throws:

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

Have I just deleted databases?(

In /etc/init.d/ currently there are asterisk functions netconsole network README, no mysql or mysqld folder.

olivierg avatar
us flag
first, is your mysql daemon running ? (when you do a "systemctl status mysqld.service" or "service mysqld status", what do you get ?)
Stdugnd4ikbd avatar
cn flag
@olivierg, I found solution, thanks
Score:0
cn flag

The problem was, that mariadb was not enabled in systemctl, i.e. it was not on startup, and hence was not running.

So I ran

systemctl enable mariadb.service, as far as remember (I have done it yesterday)

And rebooted the server, now it run on startup.


As for my program, I need to run on startup, I removed it from systemctl, and going to use crontab for that.

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.