Error connecting to MySQL: Can't connect to local MySQL server through socket

I used server:~# service mysqld restart

And a sites are upp and running again.

running mysql give me this.
server:~# mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

Shall I do a rebuild php anyway? the problem with empty databases is still there
 
It looks like i have this '/tmp/mysql.sock' somewhere instead of the one i put into /etc/my.cnf
 
Did you restart directadmin after modifying /usr/local/directadmin/conf/mysql.conf?
 
I used the restart button in Directadmin service monitor,

I hope that would restart Directadmin. I did it again but still get this when trying to backup databases.

Error while backing up database aeroglobal_xxxx
Error while backing up database aeroglobal_xxxx: The sql file is 0 bytes in size: /home/admin/admin_backups/aeroglobal/backup/aeroglobal_xxxx.sql
mysqldump error output: mysqldump: Got error: 2002: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) when trying to connect
 
But if i do this i get some errors.

server:~# service directadmin restart
Job for directadmin.service failed. See 'systemctl status directadmin.service' and 'journalctl -xn' for details.

server:~# systemctl status directadmin.service
â directadmin.service - SYSV: Allows users to modify their websites. They modify thier: email, subdomains, databases, dns record, etc...
Loaded: loaded (/etc/init.d/directadmin)
Active: failed (Result: resources) since Thu 2016-03-31 21:18:07 CEST; 3min 55s ago
Process: 13705 ExecStop=/etc/init.d/directadmin stop (code=exited, status=0/SUCCESS)
Process: 8352 ExecStart=/etc/init.d/directadmin start (code=exited, status=0/SUCCESS)
Main PID: 739 (code=exited, status=0/SUCCESS)

Mar 31 21:18:07 server.thndata.com directadmin[8352]: Starting DirectAdmin: [ OK ]
Mar 31 21:18:07 server.thndata.com systemd[1]: PID file /var/run/directadmin.pid not readable (yet?) after start.
Mar 31 21:18:07 server.thndata.com systemd[1]: directadmin.service never wrote its PID file. Failing.
Mar 31 21:18:07 server.thndata.com systemd[1]: Failed to start SYSV: Allows users to modify their websites. They modify thier: email, subdomains, databases...d, etc....
Mar 31 21:18:07 server.thndata.com systemd[1]: Unit directadmin.service entered failed state.
Hint: Some lines were ellipsized, use -l to show in full.


And.

server:~# journalctl -xn
-- Logs begin at Wed 2016-03-30 21:42:44 CEST, end at Thu 2016-03-31 21:23:01 CEST. --
Mar 31 21:20:31 server.thndata.com clamd[614]: SelfCheck: Database status OK.
Mar 31 21:21:01 server.thndata.com CRON[8438]: pam_unix(cron:session): session opened for user root by (uid=0)
Mar 31 21:21:01 server.thndata.com CRON[8439]: (root) CMD (/usr/local/directadmin/dataskq)
Mar 31 21:21:01 server.thndata.com CRON[8438]: pam_unix(cron:session): session closed for user root
Mar 31 21:22:01 server.thndata.com CRON[8458]: pam_unix(cron:session): session opened for user root by (uid=0)
Mar 31 21:22:01 server.thndata.com CRON[8459]: (root) CMD (/usr/local/directadmin/dataskq)
Mar 31 21:22:01 server.thndata.com CRON[8458]: pam_unix(cron:session): session closed for user root
Mar 31 21:23:01 server.thndata.com CRON[8478]: pam_unix(cron:session): session opened for user root by (uid=0)
Mar 31 21:23:01 server.thndata.com CRON[8479]: (root) CMD (/usr/local/directadmin/dataskq)
Mar 31 21:23:01 server.thndata.com CRON[8478]: pam_unix(cron:session): session closed for user root
 
Last edited:
OK, here is a solution.

Updated version of /etc/my.cnf:

Code:
[mysql]
socket = /usr/local/mysql/data/mysql.sock

[mysqld]
socket = /usr/local/mysql/data/mysql.sock
local-infile = 0

[B][mysqldump][/B]
[B]socket = /usr/local/mysql/data/mysql.sock[/B]

p.s. if your /etc/my.cnf has more instructions then update it, do not overwrite. If you overwrite it, it might break MariaDB/MySQL.
 
Thanks Alex.

Super nice having you checking my server and helping me to sort things out. And great that you posted the solution here.

Thanks again
Jukka
 
Thank you, my problem has been fixed by the guide, I just added this line to my.cnf and then restarted mysql.
socket=/usr/local/mysql/data/mysql.sock

service mysql restart
 
Back
Top