Over the weekend I started having all kinds of problems with mysql. I upgraded to Yosemite a while ago and was able to get mysql working. But all of a sudden, my computer is shutting down when I put it to sleep, and when I turn it on in the morning, mysql won't start.
In order to fix this over the weekend, I reinstalled mysql via homebrew, which also required porting over my data/ files and updating the permissions correctly – kind of a pain. I'd rather not do that again.
When I try to restart mysql from the command line I get (There is no shsair.local.pid file btw):
ERROR! The server quit without updating PID file (/usr/local/var/mysql/shsair.local.pid)
I eventually got things to work by updating my.cnf to include:
innodb_force_recovery = 6 (I have no idea what that does or if I should keep it)
But just to see if it was working or not, I tried to start and stop mysql with:
mysql.server stop
and it just hangs. I see this same behavior if I try to restart the computer (it hangs for a long time before shutting off, and I assume because it's trying to shut down mysql.
I'm up for trying any changes to configurations, but it is very important I keep the data/ files as I have years of database work in there.
Thanks!
Related
I'm trying to start MySQL in safe mode but the log file just keeps spitting out:
[ERROR] InnoDB: Unable to lock ./ibdata1 error: 35
[Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.
Notes:
I've stopped all mysql processes and have checked using the ps command
I've read this having repeated trouble with MySQL and Snow Leopard - Unable to lock ./ibdata1, error: 35
Just had this issue with MAMP Pro. Couldn't stop or start MySQL. Typed ps aux | grep mysql, then kill [process id] for each line. Then I could successfully launch MySQL again from MAMP Pro.
Strange error codes, both from MySQL and the operating system, can be explained by running a shell command perror which is a part of MySQL distribution. On Linux, for example, perror 35 returns OS error code 35: Resource deadlock avoided. I do not have an OSX system handy to test, but from this:
http://www.opensource.apple.com/source/xnu/xnu-1456.1.26/bsd/sys/errno.h
I gather that error 35 is "Resource temporarily unavailable", meaning that some other process (possibly another instance of mysqld?) has already locked the file.
To debug, first I would check if there is another MySQL process running by chance (looks like you already have), and if not, reboot for good measure to make sure there are no strange stale file locks, and then try again.
Somebody has run into this error before, and found a solution:
mysql_install_db, error: 35, on a Mac OS X 10.9.1
I had a similar issue after updating MAMP from 4.x to 5.x
Unfortunately the only way that I could manage to resolve this was by manually removing all of my database files (moving them into another directory) then starting MySQL via MAMP; this seemed to work.
The files in question (for me) were in:
/Library/Application Support/appsolute/MAMP PRO/db/mysql57
All of the files in this directory (except the mysql directory) need moving somewhere else. I was then able to start MySQL.
I realise this isn't a very useful answer for most situations, but if this is a local development environment (like MAMP, as in my case) then I think losing the local databases is probably acceptable.
I am trying to setup a django website on EC2, basically I want to start MySQL server, and Uwsgi after reboot.
In order to make MySQL start on reboot, I did:
sudo cp /opt/mysql/server-5.6/support-files/mysql.server /etc/init.d/
sudo update-rc.d mysql.server defaults
In order to make Uwsgi start on reboot, I created a file /etc/init/uwsgi.conf:
description "ubuntu uwsgi instance"
start on runlevel [2345]
stop on runlevel [06]
exec uwsgi --ini /home/ubuntu/uwsgi.ini
However the problem is that I will need mysql to start first, right now it looks like Uwsgi starts first, and tried to connect to mysql, which fails, and mysql never gets started.
Could anyone help me on how to solve this issue?
Thanks in advance
When your computer starts up, it doesn't run the init.d scripts directly. Instead, depending on what's called the "runlevel", it runs the scripts in /etc/rcN.d (where N is the runlevel). You can determine the current runlevel with the runlevel command; mine returns 2 in normal operation. That means that when the computer started up, it ran the scripts in /etc/rc2.d. The contents of rc2.d are just symlinks to scripts in /etc/init.d, named according to whether they should be started or stopped, and the order they should be run.
Use the runlevel command to find out what runlevel your computer is at (probably 2), then look in /etc/rc2.d for a link named smthing like uwsgi, which will be a symlink to /etc/init.d/uwsgi, and rename it to zzz999 - or whatever it takes to get it to sort after the other entries - that will cause it to run last.
There's more information about init.d scripts and runlevels at https://www.linux.com/news/enterprise/systems-management/8116-an-introduction-to-services-runlevels-and-rcd-scripts
Even if you start MySQL before uWSGI you're not assured it will be available when uWSGI is managing requests.
At start MySQL does some checks on database, loads InnoDB indexes, recover from transaction log or it may even hang.
You shouldn't rely on that approach.
Instead add application logic that ensures you correctly handle unavailability of database, i.e. retrying or showing an error page to the user asking to retry.
I have a mysql server running on an EC2 server lamp stack. It was running just fine, but the server ran out of memory and failed. I tried restarting mysqld but kept getting this error:
mysqld dead but subsys locked
So I created a swap file and now I am able to start mysqld, however, I cannot log in with the root user and password. I have searched the web, but couldn't find anything that was similar to my situation. Any Ideas?
I was able to fix the problem by following the instructions here: http://www.howtoforge.com/reset-forgotten-mysql-root-password
On my server two websites are hosted (say abc.com and test.xyz.com)
I was trying to rebuild the DB for test.xyz.com and in the process
1.I dropped the database related to it.
2.stopped the mysql ( /etc/init.d/mysqld stop)
3.moved ibdata1 file (/var/lib/mysql/ibdata1) to /tmp/
4. tried to start the mysql
but it is not getting started and on trying to connect to database using terminal, i am getting Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'.
I tried to move back ibdata1 file from /tmp/ to /var/lib/mysql but there was already a file ibdata1. Its a wonder but now website is not working since NO DB connection.
Both the sites stopped working now. Please help
and-
/etc/init.d/mysqld status gives - mysqld (pid 31905) is running...
Thanks
Quick fix:
Stop your server
Delete the newly created ibdata1 file in /var/lib/mysql. This file is created automatically when it doesn't exist. Also note, it most likely contains the data for all your databases on the server.
Copy the ibdata1 from your tmp folder back to /var/lib/mysql
Start server again
I'll explain later, when I have more time, but I think it might be urgent for you to have that quick fix :)
UPDATE: (From comments) You can't connect, okay, the cause for this could be anything. I think the best thing to do (you don't have much to loose anyway) is you simply kill mysql.
Do
ps aux | grep mysqld
Then
kill -9 <the processnumber of mysql from the previous command>
Then do as I said earlier. And never ever simply move ibdata1 again :)
Also I'm voting to close as offtopic. Then it's going to be moved to dba.stackexchange.com which is a partner site that is more dedicated to administrating database servers. You might get better help there.
We have MySQL 5.1.45 running on a RedHat box. We needed to shut the box down for maintenance last week and had an issue.
We first closed down all connections.
Then we ran the MySQLAdmin/shutdown command.
The database appeared to hang. We waited for 30 minutes before trying Ctrl-C which gave us an error and we had to end up physically cycling the box.
Most of the documentation I can find points to InnoDB problems, but we are using MyISAM.
Is there a better way to shut down MySQL than running the Shutdown command?
Is there a way to force MySQL to shut down when it appears to hang?
service mysql stop ? I'm not so sure though...