This is my first post here, so I hope I do everything right and don't forget any important info. I'm glad for any hints, because I'm running out of ideas (if I ever had any ;)).
I am (or was) running owncloud on Raspbian Jessie (so I guess basically Debian). Suddenly owncloud stopped working. The nginx error points towards php5-fpm, further searches gave this error:
exception 'Doctrine\DBAL\DBALException' with message 'Failed to connect to the database: An exception occured in driver: SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)' in /var/www/owncloud/lib/private/db/connection.php:54
So it looks like a mysql error, and /var/run/mysqld/ is actually empty.
Following these posts 1 and
2, I tried
sudo find / -type s
resulting in this output:
/run/php5-fpm.sock
/run/fail2ban/fail2ban.sock
/run/thd.socket
/run/dhcpcd.unpriv.sock
/run/dhcpcd.sock
/run/dbus/system_bus_socket
/run/avahi-daemon/socket
/run/udev/control
/run/systemd/journal/syslog
/run/systemd/journal/socket
/run/systemd/journal/stdout
/run/systemd/journal/dev-log
/run/systemd/shutdownd
/run/systemd/private
/run/systemd/notify
find: `/proc/30933/task/30933/fd/5': No such file or directory
find: `/proc/30933/task/30933/fdinfo/5': No such file or directory
find: `/proc/30933/fd/5': No such file or directory
find: `/proc/30933/fdinfo/5': No such file or directory
In the processes with top on the other hand, mysqld and mysqld_safe show up.
mysql-client, mysql-server and php5-mysql are installed and updated to the latest versions.
I also had a look at
/etc/mysql/my.cnf
/etc/mysql/debian.cnf
both show /var/run/mysqld/mysqld.sock as socket...
/var/lib/mysql/my.cnf
mentioned here does not exist.
Additionally, it seems that I can't connect to mysql through
mysql -u user -p
at least it results in the Error 2002 as well.
Finally, I tried stopping and starting the mysql service. This resulted in the following output of
systemctl status mysql.service
mysql.service - LSB: Start and stop the mysql database server daemon
Loaded: loaded (/etc/init.d/mysql)
Active: failed (Result: exit-code) since So 2016-04-10 11:54:23 CEST; 23s ago
Process: 9777 ExecStop=/etc/init.d/mysql stop (code=exited, status=0/SUCCESS)
Process: 12878 ExecStart=/etc/init.d/mysql start (code=exited, status=1/FAILURE)
So I'm kind of lost what is going on, the problem occurs since some updates a few days ago. While writing this post, I went through all the steps again, just to be safe. At one point, I had a short glimpse at my owncloud instance in the browser, but then it was gone again. So I appreciate any help/hints!!!
Thank you very much!!!
I faced the issue: Can't connect to '/var/run/mysqld/mysqld.sock'. The problem was that mysql service was not started after installation. Once I run the following command, then it worked properly:
systemctl start mysql.service
mysql -u root -p
1.Activate log in .my.cnf
log = /var/log/mysql/mysql.log
Error logging goes to syslog. This is a Debian improvement :)
Here you can see queries with especially long duration
log_slow_queries = /var/log/mysql/mysql-slow.log
long_query_time = 2
log-queries-not-using-indexes
$ ls -l /var/run/ | grep mysqld
$ ps -ef |grep mysql
tail -f /var/log/mysql/mysql.log
restart mysql
(option) delete socket & restart mysql
Related
I am trying to connect my local MySQL server, but I am facing this error message.
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'
I tried many solutions on different websites, but none of them did not work. As an instance, I tried to kill the mysql and mysqld processes and then restart the MySQL service, but not worked.
Or I executed these lines (from another site):
sudo chmod -R u+rwx /etc/mysql/
sudo chown -R mysql.mysql /etc/mysql/
but did not work and gave me the new error message:
Job for mysql.service failed because the control process exited with error code.
See "systemctl status mysql.service" and "journalctl -xe" for details.
Could you please help me with this problem?
Thanks
Finally, after about 3 hours of searching on net, the solution founded on this site :-)
https://askubuntu.com/questions/1008298/cant-start-mysql-server-database-corruption
Edit the my.cnf (/etc/mysql/my.cnf) file and add the following lines:
[mysqld]
innodb_force_recovery = 1
then run the command:
sudo systemctl start mysql
It may do not work for the first time and you need to increment the number to 2 or 3. I will be fixed finally. :-)
I have recently bought a new laptop running Ubuntu 16.04.1 LTS (64 bit). I have installed dozens of applications, but one is giving me a major headache and any help would be gratefully received.
I start from a clean slate with regard to mysql:
sudo apt remove --purge mysql-server mysql-client mysql-common
sudo apt autoremove
sudo rm -rf /var/lib/mysql*
sudo apt install mysql-server
I install my database from backup and everything works fine.
I power-off/power-on the laptop and mysql isn't working. Firstly the daemon is not running:
ps -A | grep sql
2056 ? 00:00:00 mysql-systemd-s
but something I don't recognise called mysql-systemd-s is running.
It is now impossible to use mysql:
mysql -u root -p
Enter password:
ERROR 2013 (HY000): Lost connection to MySQL server at 'reading initial
communication packet', system error: 104
The service seems to be unstartable:
service mysql start
Job for mysql.service failed because the control process exited with
error code. See "systemctl status mysql.service" and "journalctl -xe"
for details.
but neither of these is useful. The /var/log/mysql/error.log has a little more information:
......
2017-01-13T21:01:04.926244Z 0 [Warning] Failed to set up SSL because
of the following SSL library error: SSL context is not usable without
certificate and private key
2017-01-13T21:01:04.926272Z 0 [Note] Server hostname (bind-address):
'127.0.0.1'; port: 3306
2017-01-13T21:01:04.926288Z 0 [Note] - '127.0.0.1' resolves to
'127.0.0.1';
2017-01-13T21:01:04.926327Z 0 [Note] Server socket created on IP:
'127.0.0.1'.
2017-01-13T21:01:04.927774Z 0 [ERROR] Fatal error: mysql.user table is damaged. Please run mysql_upgrade.
2017-01-13T21:01:04.927897Z 0 [ERROR] Aborting
However, the recommendation to run mysql_upgrade is useless because one can't run mysql_upgrade unless the mysql server is running! And the mysql server isn't running because of this error.
So, I remove and re-install everything and run mysql_upgrade. This seems to complete without error. But, again when I power cycle the machine, I'm back without mysql working.
I have also tried starting the mysqld with the --skip-grant-tables options, but this still does not allow connexion.
At the moment, every time I reboot my computer I have to remove all traces of mysql, re-install mysql and then reload my database from a backup. This is a real pain.
Does anyone have any ideas about what's happening?
Problem appears to be resolved. The clue was that mysqld seemed to survive a power-off/power-on if I didn't restore my own database backup. It didn't if I did restore that backup.
Generally, I never look at my database backups; rather I just do a mysqldump and keep the resulting file in case of a rainy day.
Given the clues above, I took a look at the file that had been produced by mysqldump and reduced it to its minimum size so that it just contained the database that I wanted to restore. That appears to have done the trick.
I have kept the bad file and have been playing with diffs to find what was nasty in it, but haven't yet found it.
I have installed Centos7 update, removed MariaDB and done a fresh install of MySQL - additionally I have removed it and reinstalled it but everytime I connect to mysql -u root -p I get the titled error. Additionally I have looked at other tickets associated with this but still not making progress. If I run service mysqld restart it says "Redirecting to /bin/systemctl restart mysqld.service" and then just hangs. Really not a linux expert so not sure what is causing this?
I had the same problem and found out a few things after digging around. MariaDB is a drop-in replacement for mysql. On the new system, mysql is the MariaDB client (although I'm not clear on what that means). I checked to see if the service was running:
service mysqld status
which indicated:
Redirecting to /bin/systemctl status mysqld.service
mysqld.service
Loaded: not-found (Reason: No such file or directory)
Active: inactive (dead)
In other words, the mysqld service is not running.
Starting the service worked for me:
`systemctl start mariadb.service`
Now all the mysql commands work as expected.
To tie the last knot, enable the service at boot:
`systemctl enable mariadb.service`
Check the 'socket=' entry in your /etc/my.cnf within the [mysqld] section:
[mysqld1]
socket = /tmp/mysql.sock1
An alternate method is to provide the '-hhost' & '-Pport' parameters to the 'mysqladmin' or 'mysql' commands, to avoid using the socket.
mysql -u user -hservername -P3006 -p -Dschema
mysqladmin -u user -p -hhostname -Pport
Removing the dir fixed it - deleted the dir (with rm -rf "dir name") and then unintalled mysql "yum remove mysql mysql-server" then reinstalled "yum install mysql-server" and ran "service mysqld start"
If you have this problem with the start mysql service hanging - check the logs /var/log/mysqld.log as suggested by Jeremiah.
If you look into the MariaDB log file, you may see that the issue is related to creating pid file. To solve it: create the PID directory then change its owner to mysql:mysql
Hello when I try to start up my mysqld I get this error:
[root#localhost /]# service mysqld restart
Stopping mysqld: [ OK ]
MySQL Daemon failed to start.
Starting mysqld: [FAILED]
the main reason is that my.cnf file can't find my mysql.sock file.
[root#localhost /]# mysqladmin -u root -p status
mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/var/lib/mysql/mysql.sock' exists!
When I try to search it with :
sudo find / -type s | grep mysqld.sock
I'll get
find: ‘/proc/3253/task/3253/fd/5’: Bestand of map bestaat niet
find: ‘/proc/3253/task/3253/fdinfo/5’: Bestand of map bestaat niet
find: ‘/proc/3253/fd/5’: Bestand of map bestaat niet
find: ‘/proc/3253/fdinfo/5’: Bestand of map bestaat niet
"Bestand of map bestaat niet" == "File or directory don't exists"
I'm new at this so can anyone help me please?
What a pain! I stumbled upon same problem (on RedHat) and this helped me:
service mysqld stop
rm -rf /var/lib/mysql/*
service mysqld start
mysql_secure_installation
Hope that helps. Good luck!
"the main reason is that my.cnf file can't find my mysql.sock file."
Nope. "THE MAIN REASON" is mysqld has not started, so there is no mysql.sock and any client cannot establish connection.
Currently "why mysqld failds" is broad question. MySQL Error log has the reason 'Why MySQL fails'. If you know where mysql error log is, just open it, and post error message into you question.
But probably I guess you don't know where mysql error log is....
Identify where mysql error log is
So, we need to identify where it is. we could guess somewhere... but the exact approach is using strace
$ strace -f > strace.log 2>&1 service mysqld start
now strace.log has all system call related to MySQL Deamon. open strace.log with any editor and search 'err"'. in my case
[pid 26976] open("/XXX/hostname.err", O_WRONLY|O_CREAT|O_APPEND, 0666) = 3
when open() fails
It could happen open() fails, common error is
'2' for 'no such file or directory' means 'there is no /XXX directory.
'3' for 'permission denied' means you (or user in my.cnf) don't have write permission on 'XXX'
so you can find why mysqld fails to start in '/XXX/hostname.err'. we highly appreciate if you post error message.
p.s.
I have test strace with
$ strace -f > strace.log 2>&1 mysql.server start
Not sure working with service mysqld, but no reason not to work
UPDATE
"I don't get anything in return with: $ strace -f > strace.log 2>&1 service mysqld start "
Actually service mysqld start invokes /etc/rc.d/init.d/mysqld start (assuming CentOS or Fedora). so, you could try.
$ strace -f > strace.log 2>&1 /etc/rc.d/init.d/mysqld start
If my.cnf which you referenced is right file for mysqld, open it and search [mysqld] section. It looks like as follows
[mysqld]
user = username
port = 1111
basedir = /path/
datadir = /path/data
MySQL error log is in /path/data
Am not an expert in mysql but the question is:
Is mysql listening on a socket, on a tcp port or both?
check the my.cnf configuration file which usually is in /etc or /etc/mysql and you will see this. Also, if it is already running as a socket, you will see the path to the socket.
Hope it helps.
Regards
From your post, it seems mysqld failed to start MySQL Daemon failed to start.
Starting mysqld: [FAILED].
Check if mysqld is running service mysqld status.
The config file my.cnf is looking for mysql.sock and you were looking for mysqld.sock. Two different names.
Thanks Barmaley, for the awesome answer. I checked my mysqld.log file.
It show all the reasons why my mysql service not starting. In my case the user mysql has no write permission to "/var/run/mysqld". I gave permission to mysql user from root user and it worked for me.
Thanks again! Barmaley
Tech Set up:
Vagrant (Centos 6.6, MySQL 6.6) on top of MacOS Captain
Every time when I try to run mysql on Centos, I see this problem, I am not sure If this problem is only specific to OS and MySQL version.
If you open the log files and check you will see something like this
/usr/sbin/mysqld: File '/var/log/mysql-bin.index' not found (Errcode:
13 - Permission denied)
That Permission Denied is because by default we don't have permissions to write into /var/log files, so we should change permissions for the user. MySQL is trying to write something into bin-log or relay-logs located in /var/log/mysql.
Before we change permissions, we need to realize that there is no mysql directory in /var/log so, we need to create that first and then change permissions.
So, I did this:
mkdir mysql
chown mysql: mysql
mysqld should start working now!
I ran into troubles with MySQL on my CentOS.
I had some problems and backed up my database and removed mysql with all dependencies.
After that I ran reinstalled:
yum groupinstall "MySQL Database"
Installed without errors.
Running the mysql daemon:
service mysqld start
Timeout error occurred trying to start MySQL Daemon.
Starting MySQL: [FAILED]
I also ran
# /usr/bin/mysql_install_db --user=mysql
Installing MySQL system tables...
120112 1:49:44 [ERROR] Error message file '/usr/share/mysql/english/errmsg.sys' had only 480 error messages,
but it should contain at least 481 error messages.
Check that the above file is the right version for this program!
120112 1:49:44 [ERROR] Aborting
Installation of system tables failed!
Examine the logs in /var/lib/mysql for more information.
You can try to start the mysqld daemon with:
/usr/libexec/mysqld --skip-grant &
and use the command line tool
/usr/bin/mysql to connect to the mysql
database and look at the grant tables:
shell> /usr/bin/mysql -u root mysql
mysql> show tables
Try 'mysqld --help' if you have problems with paths. Using --log
gives you a log in /var/lib/mysql that may be helpful.
The latest information about MySQL is available on the web at
http://www.mysql.com
Please consult the MySQL manual section: 'Problems running mysql_install_db',
and the manual section that describes problems on your OS.
Another information source is the MySQL email archive.
Please check all of the above before mailing us!
And if you do mail us, you MUST use the /usr/bin/mysqlbug script!
Checking the logs:
less /var/log/mysqld.log
Log file is empty. I don't even know how to debug it and not sure what to do.
Any recommendations?
Thank you
I know you asked this a long time ago, but since people who search for "Timeout error occurred trying to start MySQL Daemon." may end up here, there are several possible solutions to that error. Here are some of them:
First, instead of running service mysqld start or service mysqld restart try running:
$ service mysqld stop; mysqld_safe &
There are known problems with the mysqladmin lines in the /etc/init.d/mysqld script.
If this isn't working, try the following things: check if there is enough free disk space (especially in /var):
$ df -h
Check for possible error messages in these files (not all of them may exist):
# tail -n 30 /var/log/messages
# tail -n 30 /var/log/mysqld.log
# tail -n 30 /var/lib/mysql/*.err
# tail -n 30 /var/log/mysql/error.log
Next up, make sure that /etc/my.cnf uses...
socket=/var/lib/mysql/mysql.sock
...and that the directory /var/lib/mysql/ actually exists.
Set the correct permissions and ownerships:
# chown -R mysql.mysql /var/lib/mysql/
# chmod g+w /var/run/mysqld/
# chgrp mysql /var/run/mysqld/
Still not working? Try changing the bind-address in my.cnf to 127.0.0.1 or 0.0.0.0, or comment out that line.
If you're still out of luck, search for more information about mysql_install_db and since your InnoDB database may be broken also look into set-variable=innodb_force_recovery=6.
Hey sometimes it's because you ran out of disk space... so run a cursory df -h to be sure! (This JUST happened to me :P).
Before starting the mysql server rename files /var/lib/mysql/ib_logfile0 and /var/lib/mysql/ib_logfile0 then restart the server
in linux/unix
mv /var/lib/mysql/ib_logfile0 /var/lib/mysql/ib_logfile0_old
mv /var/lib/mysql/ib_logfile1 /var/lib/mysql/ib_logfile1_old
then
service mysqld restart
In my case the cause was that i set key_buffer_size in /etc/my.cnf when i commented it out, mysqld started ok.
Try This:
rm $(grep socket /etc/my.cnf | cut -d= -f2) && service mysqld start