MySQL is waiting why can I log in from the command line? - mysql

On Ubuntu 12.04, I run sudo service mysql stop. It responds mysql stop/waiting.
But then I can still log in to mysql from the command line. How is this possible?

service mysql stop
[ ok ] Stopping MySQL database server: mysqld.
If your server has stopped this message would have appeared. Since it didn't it means that MySQL is still running and that is why you could have still logged in. You can try the more brutal method
ps -C mysqld -o pid=
//You will get a pid, which is the process identification number, say it is 8082 then
kill -9 8082
PS: Please do note replace 8082 with the pid you see in the screen

Related

Not To Start MySql Automatically at Centos Startup

i have "CentOS 6" VPS and i wanted to start mysql service automatically at Startup of Server when it is restarted. so i used this command in putty
chkconfig --level 345 mysqld on
this command is working and mysql starts on every startup automatically.
BUT how can i now stop this? what if i want to start Mysql manually on every startup, then what command should i use?
also what is the File where i can see the list of programs that are running automatically on every setup.
Thanks
You can turn off auto-start with this command:
chkconfig --level 345 mysqld off
To see what is configured for auto-start, you can run:
chkconfig --list
See more info on chkconfig here:
https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Deployment_Guide/s2-services-chkconfig.html

CircleCI: MySQL starts on its own even after stopping the process

I am having some trouble with default MySQL installation on CircleCI. In 'post' section of 'machine', I stop mysql using, "- sudo service mysql stop". The reason behind doing so is that I want to use docker mysql container on port 3306. My "docker-compose up" takes some time to finish and sometimes before the docker mysql container starts, the mysql process starts again for no reason obvious to me. I have been tracking this issue using the following command.
while true; do sudo netstat -nlp | grep :3306; sleep 2; done
I have a build that ran fine with docker being able to register port 3306, and also a build in which mysqld started again even after stopping giving me the following error on docker-compose up.
ERROR: for dbm01 Cannot start service dbm01: failed to create endpoint minimum_dbm01_1 on network minimum_default: Error starting userland proxy: listen tcp 0.0.0.0:3306: bind: address already in use
ERROR: Encountered errors while bringing up the project.
Both the builds are of same commit so there is no difference in code. What might be the issue?

Can mysqld process be killed?

I tried to kill mysql process since it was giving me an error as:
The server quit without updating PID file. But whenever I killed the process by PID, it created a new PID and the process persisted. Any explanation on this issue will be appreciated! The code I tried was as follows:
ps aux | grep mysql
sudo kill -9 [PID]
MySql was installed on Mac from .dmg file. And it was initially working fine, the error happens after it has already worked for a while.
have you tried to stop it using the daemon manager with service (linux):
service mysql stop
and for Mac:
sudo /usr/local/mysql/support-files/mysql.server stop
Hope it helps.

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

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

Why do I get "MySQL is not running but lock exists"?

I am getting this error
mysql is not running but lock exist
when I am checking the status of MySQL server. I have removed the lock files using following command:
rm /var/lock/subsys/mysql
but still I am getting same error.
Can anyone provide any input on this.
try using the unix lsof command to see which program has the lock
lsof | grep mysql
EDIT:in fact, run lsof on the lock itself
lsof /var/lock/subsys/mysql
I had the same error. It started after an unexpected server reboot. I saw there is a default /etc/my.cnf file which is not in use for my installation. The issue resolved when it renamed my.cnf as my.cnf_old
For this similar error:
service mysql status ERROR! MySQL is not running, but lock file
(/var/lock/subsys/mysql) exists
Follow these steps:
rm /var/lock/subsys/mysql rm:
remove regular empty file
/var/lock/subsys/mysql? y
Press y
/etc/init.d/mysql start.
If the error occurs again after starting MYSQL
then execute ps -ef | grep mysql
Kill all processes of MySQL and repeat steps 1 & 2.
I know this post is a quite old, but I like to make notes on the ones that work for issue that I've experienced recently. I was getting the following message, which lead me here:
service mysql status ERROR! MySQL is not running, but lock file
(/var/lock/subsys/mysql) exists
These are the steps that fixed my issues:
mv /etc/my.cnf /etc/my.cnf_old
rm /var/lock/subsys/mysql
/etc/init.d/mysql start
Starting MySQL.210921 16:46:28 mysqld_safe Logging to '/var/lib/mysql/server001.err'.
210921 16:46:28 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql. SUCCESS!