How to kill mysql started with "mysql_safe" script? - mysql

Short version: I started mysql with mysql_safe and I can't kill it.
Long version: Installing an older version of mysql with macport displayed this suggestion:
$ sudo port install mysql55-server
---> Computing dependencies for mysql55-server
---> Fetching archive for mysql55-server
---> Attempting to fetch mysql55-server-5.5.49_0.darwin_14.noarch.tbz2 from https://packages.macports.org/mysql55-server
---> Attempting to fetch mysql55-server-5.5.49_0.darwin_14.noarch.tbz2.rmd160 from https://packages.macports.org/mysql55-server
---> Installing mysql55-server #5.5.49_0
---> Activating mysql55-server #5.5.49_0
If this is a new install you might want to run:
$ sudo -u _mysql /opt/local/lib/mysql55/bin/mysql_install_db
Running that gave these instructions:
$ sudo -u _mysql /opt/local/lib/mysql55/bin/mysql_install_db
Installing MySQL system tables...
161102 13:15:44 [Note] /opt/local/lib/mysql55/bin/mysqld (mysqld 5.5.49) starting as process 54176 ...
OK
Filling help tables...
161102 13:15:44 [Note] /opt/local/lib/mysql55/bin/mysqld (mysqld 5.5.49) starting as process 54180 ...
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/opt/local/lib/mysql55/bin/mysqladmin -u root password 'new-password'
/opt/local/lib/mysql55/bin/mysqladmin -u root -h myusername password 'new-password'
Alternatively you can run:
/opt/local/lib/mysql55/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd /opt/local ; /opt/local/lib/mysql55/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd /opt/local/mysql-test ; perl mysql-test-run.pl
Please report any problems at http://bugs.mysql.com/
At this point I (unwisely, it seems) ran:
$ cd /opt/local ; /opt/local/lib/mysql55/bin/mysqld_safe &
Now I cannot figure out how to stop the mysql and/or daemondo process(es):
$ ps aux | grep mysql55
myusername 54937 0.1 0.0 2432772 660 s001 R+ 1:39PM 0:00.00 grep mysql55
_mysql 54888 0.0 0.1 2667884 6340 ?? S 1:36PM 0:00.12 /opt/local/lib/mysql55/bin/mysqld --user=_mysql
root 54885 0.0 0.0 2479468 700 ?? Ss 1:36PM 0:00.00 /opt/local/bin/daemondo --label=mysql55-server --start-cmd /opt/local/lib/mysql55/bin/mysqld --user=_mysql ; --pid=exec
I've tried many variations of kill, targeting both mysql (which seems pointless) and daemondo, including (but not limited to) the following:
sudo kill -9 54888 // killing the mysql process results in a new pid
sudo kill 54885 // the doemondo process
sudo kill -SIGHUP 54885
sudo killall mysqld_safe
sudo kill -9 54822 // a reincarnation of the doemondo process
sudo mysqladmin shutdown

For centos or mint
/usr/bin# initctl
for ubuntu
pkill mysqld

Related

How to stop mysql on OsX from the command line

This question bas many answers, I tried what I found – did not work
So, I tried sudo mysqld stop.
Still I see the mysql processes running:
0 317 1 0 11:15AM ?? 0:00.02 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/usr/local/mysql/data --pid-file=/usr/local/mysql/data/anarinsky-mbp.smartdestinations.com.pid
74 3562 317 0 11:40AM ?? 0:00.41 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/usr/local/mysql/data/anarinsky-mbp.smartdestinations.com.err --pid-file=/usr/local/mysql/data/anarinsky-mbp.smartdestinations.com.pid
The same happens if I do “sudo kill -9 3562”.
Trying to go to /Library/LaunchDaemons does not retrieve any mysql entries
ls /Library/LaunchDaemons | grep mysql
The service command does not work:
-bash: service: command not found
My Os X version is 10.9.2
There are two answers I know, it might not help since you search a long time.
1.if you install mysql from dmg, you can close it in "system preferences".
2.And besides that, you can start/stop/restart mysql by:
sudo /usr/local/mysql/support-files/mysql.server start
sudo /usr/local/mysql/support-files/mysql.server stop
sudo /usr/local/mysql/support-files/mysql.server restart
To install Homebrew, open Terminal/iTerm and run following command or check https://brew.sh/
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Install mysql
$ brew install mysql.
Install brew services first
$ brew tap homebrew/services.
Start mysql
$ brew services start mysql.
In order to avoid mysqld from auto restarting after killed, try execute all these 3 commands:
$ brew services stop mysql
$ sudo launchctl unload /Library/LaunchDaemons/com.mysql.mysql.plist
$ sudo launchctl unload /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist

Finding errors in this step of mysql installation in ubuntu 14.04 "sudo mysql_install_db "

Installing MySQL system tables...
150623 11:01:43 [Note] /usr/sbin/mysqld (mysqld 5.5.43-0ubuntu0.14.04.1)
starting as process 24482 ...
OK
Filling help tables...
150623 11:01:43 [Note] /usr/sbin/mysqld (mysqld 5.5.43-0ubuntu0.14.04.1) starting as process 24488 ...
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h praveen password 'new-password'
Alternatively you can run:
/usr/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd /usr/mysql-test ; perl mysql-test-run.pl
Please report any problems at http://bugs.mysql.com/
Please refer below link to install phpmyadmin
phpMyAdmin Installation

MySql server PID not found

I have CentOS 6.4 with NGINX.
When I try to start/stop/restart mysql server (/etc/init.d/mysqld restart) I get this error:
MySQL server PID file could not be found! [FAILED]
Starting MySQL..The server quit without updating PID file ([FAILED]/mysql/mysqld.pid).
What can I do to solve this problem?
Thanks!
I got the same error on a CentOS 6.3 where I upgraded MySQL to 5.6.14 but I kept the old my.cnf file. After upgrade, MySQL did not start anymore, giving me the same error as you described.
The problem was that I had this setting in my.cnf:
table_cache=2048
According to this link table_cache renamed table_open_cache..
"Seem like in 5.5 the system variable table_cache was renamed
table_open_cache..
In 5.6 mysqld fails if it finds an unknown variable
this means that upgrades from versions earlier than 5.5 can have
problems if table_cache is specified in my.cnf."
After I changed the above line to
table_open_cache=2048
MySQL started perfectly.
So, in the case you have MySQL 5.5+ (and maybe an older my.cnf), I suggest you to do the following:
remove my.cnf from /etc folder and try to start MySQL
if MySQL starts, the the problem is in my.cnf. Comment/uncomment all the settings one by one in order to see which is causing the problem.
Hope this helps.
I upgraded my Mac OS to 10.9.3 and encountered the above problem on mysql.server restart
The following fixed my problem
sudo chmod -R o+rwx /usr/local/var/mysql/
sudo chown -R mysql /usr/local/var/mysql/
sudo mysql.server restart
First of all make sure that which folder/file is not exist in /var/run/mysqld/mysqld.pid
if dir not exists then create it as:
sudo mkdir -p /var/run/mysqld/
if mysqld.pid is not exists then create it as:
sudo touch /var/run/mysqld/mysqld.pid
change ownership as:
sudo chown mysql:mysql -R /var/run/mysqld
chmod 775 -R /var/run/mysqld
restart mysql service
sudo service mysql restart
I find that sometimes MySQL processes are still running. Certainly this was the case on my OS X Yosemite system so use the following command to find any processes that show up with MySQL in the name:
ps aux | grep mysql
Then kill them using the command
sudo kill -9 PID, replacing PID with the offending process ID.
Check if there is a lock.
/etc/init.d/mysql status
If the OS says that there is a lock, something like:
ERROR! MySQL is not running, but lock file (/var/lock/subsys/mysql) exists
remove that lock file and restart.
I found this worked....
# ps aux | grep mysql
root 3668 0.0 0.0 11432 1240 ? S 2014 0:00 /bin/sh /usr/bin/mysqld_safe --datadir=/db/data01 --pid-file=/var/lib/mysql/mysql.pid
mysql 5303 0.1 0.4 1964748 12368 ? S<l 2014 1663:35 /usr/sbin/mysqld --basedir=/usr --datadir=/db/data01 --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --log-error=/db/logs01/mysql-error.err --open-files-limit=8192 --pid-file=/var/lib/mysql/mysql.pid --socket=/var/lib/mysql/mysql.sock --port=3306
root 12369 0.0 0.0 6376 680 pts/0 S+ 09:05 0:00 grep mysql
# kill -9 3668 5303
# rm /var/lock/subsys/mysql rm: remove regular empty file `/var/lock/subsys/mysql'? y
# service mysql start Starting MySQL (Percona Server).. SUCCESS!

MySQL deactivated in Lampp, Xampp on Linux 12.04

I have freshly installed xampp-linux-1.8.1 on my Ubuntu 12.04 (Mint 13 maya) Operating system.
When run lampp, I get :
/opt/lampp/lampp start
Starting XAMPP for Linux 1.8.1...
XAMPP: XAMPP-Apache is already running.
XAMPP: Another MySQL daemon is already running.
XAMPP: XAMPP-ProFTPD is already running.
XAMPP for Linux started.
In the : localhost/xampp/
MySQL DataBase is Deactivated !!!
ps -aux | grep 'mysql'
Warning: bad ps syntax, perhaps a bogus '-'? See http://procps.sf.net/faq.html mysql 3159 0.0 0.9 316264 31880 ? Ssl 16:48 0:00 /usr/sbin/mysqld
root 4745 0.0 0.0 4648 840 pts/5 S+ 17:02 0:00 grep --color=auto mysql
When I tried to stop /usr/sbin/mysqld but it can't be stopped with this command !!!
/usr/sbin/mysqld stop
Please I need Help, Thanks.
i've resolved the issue in this way:
sudo chmod -R 777 /opt/lampp
sudo chown -hR nobody /opt/lampp
sudo chmod -R 755 /opt/lampp
then stop other mysqld running with:
sudo service mysql stop
Also had this issue, after troubleshooting for almost 2 hours I found that it was because of other Apache and MySQL packages also running on my system. Removed all Apache and MySQL packages and reinstalled XAMPP again. Success.

How to start MySQL server from command line on Mac OS Lion?

I installed mySQL on my Mac. Beside starting the SQL server with mySQL.prefPane tool installed in System Preferences, I want to know the instructions to start from command-line.
I do as follows:
After
su root
I start the mySQL server by command-line, but it produces an error as below:
sh-3.2# /usr/local/mysql/bin/mysqld
111028 16:57:43 [Warning] Setting lower_case_table_names=2 because
file system for /usr/local/mysql-5.5.17-osx10.6-x86_64/data/ is case
insensitive
111028 16:57:43 [ERROR] Fatal error: Please read "Security" section of
the manual to find out how to run mysqld as root!
111028 16:57:43 [ERROR] Aborting
111028 16:57:43 [Note] /usr/local/mysql/bin/mysqld: Shutdown complete
Simply:
mysql.server start
mysql.server stop
mysql.server restart
Try /usr/local/mysql/bin/mysqld_safe
Example:
shell> sudo /usr/local/mysql/bin/mysqld_safe
(Enter your password, if necessary)
(Press Control-Z)
shell> bg
(Press Control-D or enter "exit" to exit the shell)
You can also add these to your bash startup scripts:
export MYSQL_HOME=/usr/local/mysql
alias start_mysql='sudo $MYSQL_HOME/bin/mysqld_safe &'
alias stop_mysql='sudo $MYSQL_HOME/bin/mysqladmin shutdown'
I like the aliases too ... however, I've had issues with MySQLCOM for start ... it fails silently ... My workaround is akin to the others ... ~/.bash_aliases
alias mysqlstart='sudo /usr/local/mysql/support-files/mysql.server start'
alias mysqlstop='sudo /usr/local/mysql/support-files/mysql.server stop'
As this helpful article states:
On OS X to start/stop MySQL from the command line:
sudo /usr/local/mysql/support-files/mysql.server start
sudo /usr/local/mysql/support-files/mysql.server stop
On Linux start/stop from the command line:
/etc/init.d/mysqld start
/etc/init.d/mysqld stop
/etc/init.d/mysqld restart
Some Linux flavours offer the service command too
# service mysqld start
# service mysqld stop
# service mysqld restart
or
# service mysql start
# service mysql stop
# service mysql restart
If you installed it with homebrew, the binary will be somewhere like
/usr/local/Cellar/mysql/5.6.10/bin/mysqld
which means you can start it with
/usr/local/Cellar/mysql/5.6.10/support-files/mysql.server start
and stop it with
/usr/local/Cellar/mysql/5.6.10/support-files/mysql.server stop
Edit: As Jacob Raccuia mentioned, make sure you put the appropriate version of MySQL in the path.
Maybe your mysql-server didn't start.
You can try
/usr/local/bin/mysql.server start
sudo /Library/StartupItems/MySQLCOM/MySQLCOM start
sudo /Library/StartupItems/MySQLCOM/MySQLCOM stop
make alias in .bash_profile
alias start_mysql="/Library/StartupItems/MySQLCOM/MySQLCOM start"
alias stop_mysql="/Library/StartupItems/MySQLCOM/MySQLCOM stop"
and if you are trying to run as root use following safe mode
sudo ./bin/mysqld_safe
if you are still having issues starting, a recommended read:
mysql5.58 unstart server in mac os 10.6.5
For me this solution worked on mac Sierra OS:
sudo /usr/local/bin/mysql.server start
Starting MySQL
SUCCESS!
My MySQL is installed via homebrew on OS X ElCaptain. What fixed it was running
brew doctor
which suggested that I run
sudo chown -R $(whoami):admin /usr/local
Then:
brew update
mysql.server start
mysql is now running
If it's installed with homebrew try just typing down mysql.server in terminal and that should be it.
AFAIK it executable will be under /usr/local/bin/mysql.server.
If not you can always run following "locate mysql.server" which will tell you where to find such file.
If you have MySQL installed through Homebrew these commands will help you:
# For starting
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
# For stoping
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
MySql server startup error 'The server quit without updating PID file '
if you have installed mysql from homebrew
close mysql server from preferences of mac
ps ax | grep mysql
#kill all the mysql process running
sudo kill -9 pid
which mysql
/usr/local/bin/mysql
Admins-MacBook-Pro:bin username$ sudo mysql.server start
Starting MySQL
. SUCCESS!
Admins-MacBook-Pro:bin username$ which mysql
/usr/local/bin/mysql
Admins-MacBook-Pro:bin username$ ps ax | grep mysql
54916 s005 S 0:00.02 /bin/sh
/usr/local/Cellar/mysql#5.7/5.7.27_1/bin/mysqld_safe --datadir=/usr/local/var/mysql --pid-file=/usr/local/var/mysql/Admins-MacBook-Pro.local.pid
55012 s005 S 0:00.40 /usr/local/Cellar/mysql#5.7/5.7.27_1/bin/mysqld --basedir=/usr/local/Cellar/mysql#5.7/5.7.27_1 --datadir=/usr/local/var/mysql --plugin-dir=/usr/local/Cellar/mysql#5.7/5.7.27_1/lib/plugin --user=mysql --log-error=Admins-MacBook-Pro.local.err --pid-file=/usr/local/var/mysql/Admins-MacBook-Pro.local.pid
55081 s005 S+ 0:00.00 grep mysql
On mac Big Sur and MySQL 5.7, I needed to stop/start with:
sudo launchctl load -F /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist
and
sudo launchctl unload -F /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist
This answer came from https://coolestguidesontheplanet.com/start-stop-mysql-from-the-command-line-terminal-osx-linux/
In my case, I had downloaded the mysql server and installed it but I didn't click on the run server that showed up on the last installer page.
In order to start my server manually in the terminal (without adding aliases), I used this in the terminal and it works.
Start Server:
sudo launchctl load -F /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist
Stop Server:
sudo launchctl unload -F /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist
More info at the link below:
https://www.databasestar.com/start-mysql-server/
111028 16:57:43 [ERROR] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root!
Have you set a root password for your mysql installation? This is different to your sudo root password. Try /usr/local/mysql/bin/mysql_secure_installation