MySQL pid ended (cannot start mysql) - mysql

I have a clean install of MySQL (mysql-5.5.24-osx10.6-x86_64). I am on Lion (OS 10.7.4) with a Mac Pro Quad Core. I installed MySQL the GUI installer and also installed the pref pane and the startup item.
However when I run:
sudo ./bin/mysqld_safe
I get this message:
120515 17:58:19 mysqld_safe Logging to '/usr/local/mysql-5.5.24-osx10.6-x86_64/data/Dannys-Mac-Pro.local.err'.
120515 17:58:19 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql-5.5.24-osx10.6-x86_64/data
120515 17:58:20 mysqld_safe mysqld from pid file /usr/local/mysql-5.5.24-osx10.6-x86_64/data/Dannys-Mac-Pro.local.pid ended
I also cannot start MySQL from the preference pane.
Here is what I have tried so far based on the hours of Googling and research today:
Permissions issues?
This:
cd /usr/local
sudo chown mysql mysql
sudo chown mysql mysql-5.5.24-osx10.6-x86_64
sudo chown _mysql mysql
sudo chown _mysql mysql-5.5.24-osx10.6-x86_64
and
sudo chown -R /usr/local/mysql-5.5.24-osx10.6-x86_64/
sudo chown -R /usr/local/mysql
This:
sudo chown -R root:wheel /Library/StartupItems/MySQLCOM
Link issues?
This:
in /usr/local/mysql/support-files/mysql.server -- I did:
basedir="/usr/local/mysql"
datadir="/usr/local/mysql/data"
In the file /etc/rc.common add the follow line at end:
/usr/local/mysql/bin/mysqld_safe --user=mysql &
This:
sudo ln -s /usr/local/mysql-5.5.24-osx10.6-x86_64 /usr/local/mysql
I also tried the removal process here and reinstalled but this did not seem to make a difference. I also launched Activity Monitor in OS X to see if any other mySQL processes were running by chance but they were not.
Nothing above worked so I am sort of at wits end. Here is the log from the .err file located at:
/usr/local/mysql-5.5.24-osx10.6-x86_64/data/Dannys-Mac-Pro.local.err
120515 18:07:43 mysqld_safe mysqld from pid file /usr/local/mysql-5.5.24-osx10.6-x86_64/data/Dannys-Mac-Pro.local.pid ended
120515 18:13:01 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql-5.5.24-osx10.6-x86_64/data
120515 18:13:01 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/mysql-5.5.24-osx10.6-x86_64/data/ is case insensitive
120515 18:13:01 [Note] Plugin 'FEDERATED' is disabled.
/usr/local/mysql-5.5.24-osx10.6-x86_64/bin/mysqld: Table 'mysql.plugin' doesn't exist
120515 18:13:01 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
120515 18:13:01 InnoDB: The InnoDB memory heap is disabled
120515 18:13:01 InnoDB: Mutexes and rw_locks use GCC atomic builtins
120515 18:13:01 InnoDB: Compressed tables use zlib 1.2.3
120515 18:13:01 InnoDB: Initializing buffer pool, size = 128.0M
120515 18:13:01 InnoDB: Completed initialization of buffer pool
120515 18:13:01 InnoDB: highest supported file format is Barracuda.
120515 18:13:01 InnoDB: Waiting for the background threads to start
120515 18:13:02 InnoDB: 1.1.8 started; log sequence number 1595675
120515 18:13:02 [ERROR] /usr/local/mysql-5.5.24-osx10.6-x86_64/bin/mysqld: unknown option '--skip-locking'
120515 18:13:02 [ERROR] Aborting
120515 18:13:02 InnoDB: Starting shutdown...
120515 18:13:03 InnoDB: Shutdown completed; log sequence number 1595675
120515 18:13:03 [Note] /usr/local/mysql-5.5.24-osx10.6-x86_64/bin/mysqld: Shutdown complete
120515 18:13:03 mysqld_safe mysqld from pid file /usr/local/mysql-5.5.24-osx10.6-x86_64/data/Dannys-Mac-Pro.local.pid ended
Update: I upgraded the same machine from Snow Leopard to Mountain Lion 10.8.1 and MySQL works perfectly fine now with the upgrade, I had to do nothing extra.

I have the same problem when installing mysql newest version mysql-5.6.10-osx10.7-x86.dmg for my MAC OS 10.7.5. Following is my solutions.
First , delete the mysql installed
sudo rm /usr/local/mysql
sudo rm -rf /usr/local/mysql*
sudo rm -rf /Library/StartupItems/MySQLCOM
sudo rm -rf /Library/PreferencePanes/My*
sudo rm -rf ~/Library/PreferencePanes/My*
sudo rm -rf /Library/Receipts/mysql*
sudo rm -rf /Library/Receipts/MySQL*
sudo rm -rf /var/db/receipts/com.mysql.*
Then, get mysql-5.1.68-osx10.6-x86.dmg , install this old version, and done!

As #AndPy says, the same with me, if you ls -l the /usr/local/var/mysql you can see that the file COMPUTER-NAME.local.err is owned by _mysql or some such.... in this case just erase the file and mysql.server start will create new one owned by your user and will start properly this time :)
If the file is already owned by your user, this wont help, you got to google more :(

I found this error on redmine bitnami stack because owner of files in directory data incorrect.
Check owner of directory /mysql/data/ must be 'mysql' user
Hope this help.

I had the same problem after updating to OS X Mavericks.
Starting MySQL . ERROR! The server quit without updating PID file
Like Redrick and AndPy mentioned I also had to rename (actually I deleted the file) the error file located in $ cd /usr/local/var/mysql. My error file was called localhost.err. After removing the file with $ rm localhost.err I could finally start MySQL again with $ mysql.server start.

I had the same problem.
In /usr/local/var/mysql I found a file in the form COMPUTER-NAME.local.err. Simply changing that file name solved the problem. I could now start the mysql server with
mysql.server start

My answer is very similar to others, but slightly different and this applies mostly to a bitnami mamp stack. The fix for me was:
sudo chown -R mysql mysql/
The mysql/ directory is the one located in Applications/<mampstack-version>/
The above sets the mysql to be the owner of the mysql directory recursively into the other directories.

If you want to absolutely get this thing working do the following:
You need to uninstall mysql first so do that, before you do this though, make sure you have a backup of all your DBs.
brew remove mysql
Then you need to make sure certain files are uninstalled, make a batch script of the following commands and run it:
sudo rm /usr/local/mysql
sudo rm -rf /usr/local/var/mysql
sudo rm -rf /usr/local/mysql*
sudo rm ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
sudo rm -rf /Library/StartupItems/MySQLCOM
sudo rm -rf /Library/PreferencePanes/My*
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
rm -rf ~/Library/PreferencePanes/My*
sudo rm -rf /Library/Receipts/mysql*
sudo rm -rf /Library/Receipts/MySQL*
sudo rm -rf /private/var/db/receipts/*mysql*
Go to /etc/hostconfig using your favorite editing program and remove the line MYSQLCOM=-YES-
Then run brew cleanup then install mysql using brew install mysql
After you've done this you'll probably get the same error again. Head over to the folder cd /usr/local/var/mysql/. There should be a file in there called localhost.local.err
run cat ./localhost.local.err and look in the file. You should see something similar to:
2018-03-24 15:41:49 140735679804288 [ERROR] Can't start server: Bind on TCP/IP port. Got error: 48: Address already in use
2018-03-24 15:41:49 140735679804288 [ERROR] Do you already have another mysqld server running on port: 3306 ?
If you do, run the command sudo lsof -i :3306 and you'll probably get something back like this:
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
mysqld 74 _mysql 20u IPv6 0xXXXXXXXXXXXXX 0t0 TCP *:mysql (LISTEN)
This means mysql is already running and listening on port 3306 and you need to kill it. Use top to kill the program or just use Activity Monitor to kill it. Either way once that's done go back to cd /usr/local/var/mysql/ and delete the folder localhost.local.err.
Once that's done run mysql.server start and you should get the following:
180324 15:46:18 mysqld_safe Starting mysqld daemon with databases from /usr/local/var/mysql
SUCCESS!
And congrats. I've been trying to fix this for a week and it's such an easy fix and I just figured it out. I hate myself.

120515 18:13:01 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
Regarding this error, I assume that you have specified a datadir in my.cnf. If you are using a non-default data directory for MySQL, you need to move folders mysql and performance_schema (whichever exists) to the data directory specified in my.cnf. You can find these folders in mysql directory.
In MySQL 5.5+ the --skip-locking option is removed. Use --skip-external-locking instead. Refer to MySQL documentation --> http://dev.mysql.com/doc/refman/5.5/en/mysql-nutshell.html
Quote: "The --enable-locking and --skip-locking server options (use --external-locking and --skip-external-locking)."

Give this a whirl..
Navigate to the problem's parent directory cd YOURPATH/usr/local/mysql
rm -rf *.local.err (deletes file)
touch YOURUSERNAME.local.pid (generates new *.local.pid file the error thrown was complaining about)
cd back into your project and restart mysql using mysql.server start

Only removing mysql-bin.index file in /usr/local/var/mysql/ helped me.

I've tried many hours, But this works for me,
Simply change the ownership of the MySQL directory file to the user called 'mysql'.
chown -R mysql <path>/mysql-5.7.39-linux-glibc2.12-x86_64

Related

cannot touch `/var/log/mysqld.log': Permission denied

i have reinstalled mysql server in cent OS RHEL5.5 , Im getting the following error
touch: cannot touch `/var/log/mysqld.log': Permission denied
chown: changing ownership of `/var/log/mysqld.log': Operation not permitted
chmod: changing permissions of `/var/log/mysqld.log': Operation not permitted
MySQL Daemon failed to start.
Starting mysqld: [FAILED]
I have checked the permissions for log files , its having correct permissions as mysql user
-rw-r----- 1 mysql mysql 5931 Mar 9 04:36 mysqld.log
Please let me know the issue on this and how to solve it.
Thanks
Ok. I have solved the issue,
$ /usr/libexec/mysqld --skip-grant &
[1] 5388
InnoDB: Error: log file ./ib_logfile0 is of different size 0 50331648 bytes
InnoDB: than specified in the .cnf file 0 5242880 bytes!
150312 10:03:28 [Note] /usr/libexec/mysqld: ready for connections.
Version: '5.0.95' socket: '/var/lib/mysql/mysql.sock' port: 3306 Source distribution
$ rm -rf /var/lib/mysql/ib_logfile0
$ rm -rf /var/lib/mysql/ib_logfile1
$ ls -l /var/lib/mysql
i have removed the log files and restart the mysql server.
Thanks
The workaround is:
$ sudo touch /var/log/mysqld.log
$ sudo chown mysql:mysql /var/log/mysqld.log
$ sudo chcon system_u:object_r:mysqld_log_t:s0 /var/log/mysqld.log
In my case, this happened to me after downgrading an AWS EC2 instance. The error was as follows:
$ service mysqld start
touch: cannot touch ‘/var/log/mysqld.log’: Permission denied
chown: changing ownership of ‘/var/log/mysqld.log’: Operation not permitted
chmod: changing permissions of ‘/var/log/mysqld.log’: Operation not permitted
chown: changing ownership of ‘/var/lib/mysql’: Operation not permitted
chmod: changing permissions of ‘/var/lib/mysql’: Operation not permitted
MySQL Daemon failed to start.
Starting mysqld: [FAILED]
Turns out the issue was the new downgraded VM didn't have enough memory as MySQL was trying to reserve.
Updating the value reserved for InnoDB on etc/my.cnf solved the issue:
innodb_buffer_pool_size=4G
No other changes on the file system permissions were needed.
In my case, there is problem with ubuntu apparmor.
Solution:
Edit mysqld profiles (usually in /etc/apparmor.d/usr.sbin.mysqld) and make sure you have:
/var/log/mysqld.log rw,
systemctl reload apparmor
touch /var/log/mysqld.log
chown mysql:mysql /var/log/mysqld.log
chmod 0644 /var/log/mysqld.log
systemctl restart mysql

Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root

I am not sure how to fix this:
dyn-72-33-214-45:python mona$ sudo /usr/local/mysql/bin/mysqld stop
2014-09-06 09:49:04 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2014-09-06 09:49:04 22992 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/mysql-5.6.15-osx10.7-x86_64/data/ is case insensitive
2014-09-06 09:49:04 22992 [ERROR] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root!
2014-09-06 09:49:04 22992 [ERROR] Aborting
2014-09-06 09:49:04 22992 [Note] Binlog end
2014-09-06 09:49:04 22992 [Note] /usr/local/mysql/bin/mysqld: Shutdown complete
I'm using OS X (Yosemite) and this error happened to me when I upgraded from Mavericks to Yosemite. It was solved by using this command
sudo /usr/local/mysql/support-files/mysql.server start
you might try this if you logged in with root:
mysqld --user=root
The MySQL daemon should not be executed as the system user root which (normally) do not has any restrictions.
According to your cli, I suppose you wanted to execute the initscript instead:
sudo /etc/init.d/mysql stop
Another way would be to use the mysqladmin tool (note, root is the MySQL root user here, not the system root user):
/usr/local/mysql/bin/mysqladmin --port=8889 -u root shutdown
Try this for Amazon Linux AMI or for centOS
sudo service mysqld restart
How i resolved this was following the 4th point in this url: https://dev.mysql.com/doc/refman/8.0/en/changing-mysql-user.html
Edit my.cnf
Add user = root under under [mysqld] group of the file
If this doesn't work then make sure you have changed the password from default.
I also had the same problem and able to resolve after using below command
/root/mysql-sandboxes/3320/bin/mysqld --defaults-file=/root/mysql-sandboxes/3320/my.cnf --user=root &
osx could be using launchctl to launch mysql. Try this:
sudo launchctl unload -w /Library/LaunchDaemons/com.mysql.mysqld.plist
Donal had the right solution for me. However, the updated plist name for 2017 is
com.oracle.oss.mysql.mysqld.plist.
in my case (RHEL7 and MariaDB) this works.
sudo systemctl restart mariadb
On top of #mise's answer,
After I installed MacOS Mojave, I also had to change files ownership on all my MAMP directory and contents).
From the Finder, I went in Application/MAMP, showed files info (cmd + i) and in permissions section added myself with read & write perms, then from the little gear applied to all the children.
The correct answer that worked for me on CentOS is
/etc/init.d/mysql restart
which is an init script and not /etc/init.d/mysqld restart, which is binary
The is in fact comment of #MrTux on the question which worked for me. It took quite a bit of my time hence posting it as answer.
to run mysqld as root user from command line you need to add the switch/options
--user=root
mariadb run as system root user
I had this issue while running MySQL on Minikube (Ubuntu box) and I solved it with:
sudo ln -s /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/
sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld
Very weird, but I got this error when I made a typo in the my.cnf file.
So it had nothing to do with the user directive not defined or not running as root-user.
My mistake was:
bind=192.168.1.2
instead of
bind-address=192.168.1.2

Can't get MySQL to work on OS X 10.9

I know there are tons of posts about this problem but, I have tried all the solutions I have seen, and none are working. I have been working on this for two days now...it seems like I should be able to get a simple install working. Here are the facts:
I downloaded mysql-5.6.15-osx10.7-x86_64.dmg from the MySQL site. I opened and ran the mysql-5.6.15-osx10.7-x86_64.pkg. Then I went to the command line and tried a long list of commands to start MySQL and NOTHING works.
Here is a list of some of my attempts and their results:
~ $ mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/mysql/mysql.sock' (2)
~ $ mysqld
2014-01-13 19:52:20 0 [Warning] Using unique option prefix key_buffer instead of key_buffer_size is deprecated and will be removed in a future release. Please use the full name instead.
2014-01-13 19:52:20 0 [Warning] Using unique option prefix thread_cache instead of thread_cache_size is deprecated and will be removed in a future release. Please use the full name instead.
2014-01-13 19:52:20 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2014-01-13 19:52:20 953 [Warning] Can't create test file /usr/local/mysql-5.6.15-osx10.7-x86_64/data/rogerknwlessmbp.lower-test
2014-01-13 19:52:20 953 [Warning] Can't create test file /usr/local/mysql-5.6.15-osx10.7-x86_64/data/rogerknwlessmbp.lower-test
mysqld: File './mysql-bin.index' not found (Errcode: 13 - Permission denied)
2014-01-13 19:52:20 953 [ERROR] Aborting
~ $ sudo mysqld
After several warnings about deprecated settings, I got:
2014-01-13 20:27:55 1311 [ERROR] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root!
2014-01-13 20:27:55 1311 [ERROR] Aborting
2014-01-13 20:27:55 1311 [Note] Binlog end
~ $ sudo /usr/local/mysql/bin/mysqld_safe
140113 20:30:08 mysqld_safe Logging to '/usr/local/mysql/data/rogerknwlessmbp.err'.
140113 20:30:09 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
140113 20:30:11 mysqld_safe mysqld from pid file /usr/local/mysql/data/rogerknwlessmbp.pid ended
~ $ sudo /usr/local/mysql/support-files/mysql.server start
Starting MySQL
... ERROR! The server quit without updating PID file (/usr/local/mysql/data/rogerknwlessmbp.pid).
I read one post that said this was a permissions issue, and that the solution was to rebuild permissions using the Disk Utility app in Mac OS X. I have done that with no effect.
Over the past few days, I have tried so many things, I can't keep track but, they all get about the same results. I have tried installing earlier versions, different versions (x86), and on and on. If anyone has a recommendation as to what else I might try I would really appreciate it. I would love to get MySQL working on this machine. It was on my machine and working at one point but, I uninstalled it because of some problems I was having long ago. Now, I can't get it to work.
Thanks for any advice you can give.
I believe socket should link to /var/lib/mysql/mysql.sock
You can edit a file that is usually in /etc/mysql/ folder and fine a line starting with socket=
Try putting /var/lib/mysql/mysql.sock as a value for this.
I believe you can see a location for mysql.sock by running this command
$ mysqladmin variables | grep socket
If it's /tmp/mysql.sock
you can try sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock too
Finally! I got it to install and to start.
Essentially, the turning point was viewing the installation logs and working through the errors that were reported there. I had not completely removed all the old files, and one of them was causing an error.
If you are installing onto mac using the .dmg file, you can hit Ctrl+L to view the log file, and identify, specifically, what the problems are.
The MySQL portion of this guide worked for me:
Download the “x86, 64bit” DMG version of MySQL 5.6.x for OS X 10.7
from mysql.com and install the pkg, the startup item and the pref
pane.
Open the pref pane and start the MySQL Server.
Update the path by editing ~/.bash_profile and add:
export PATH=~/bin:/usr/local/bin:/usr/local/mysql/bin:$PATH
at top of file.
Set up MySQL root password:
mysqladmin -u root password {new-password}
mysqladmin -u root> -p{new-password} -h localhost password {new-password}
mysqladmin -u root -p{new-password} reload
Clear the history file by typing history -c so that {new-password}
isn’t in plain text on the disk.
Now ensure that the mysql.sock file can be found by PHP: Ensure that
MySQL is running
sudo mkdir /var/mysql sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock
This answer on StackOverflow explains it pretty well: https://stackoverflow.com/a/15472270/1067124.
Backup your your /usr/local/mysql/data/ folder first
Delete old installation (this will also remove your data!):
sudo rm /usr/local/mysql
sudo rm -rf /usr/local/mysql*
sudo rm -rf /Library/StartupItems/MySQLCOM
sudo rm -rf /Library/PreferencePanes/My*
sudo rm -rf ~/Library/PreferencePanes/My*
sudo rm -rf /Library/Receipts/mysql*
sudo rm -rf /Library/Receipts/MySQL*
sudo rm -rf /var/db/receipts/com.mysql.*
Install MySQL from http://dev.mysql.com/downloads/mysql/5.1.html
Restore /usr/local/mysql/data/
OS Yosemite and Maverick has been having these issues to DYLD_LIBRAARY PATH
Found here
Please Use this link to view the answer already on stack overflow.
I see someone has given an answer that works in the original poster's case, but as this is such a common problem I thought I'd post the solution I found to the same problem in my own case.
I thought I knew what I was doing as I had successfully installed MySQL (mysql-5.6.15-osx10.7-x86_64.dmg) on two machines running Mavericks following the procedures at https://discussions.apple.com/docs/DOC-3082, which also allow you to install Perl drivers. However when I tried on a laptop that had previously been running Snow Leopard (sic) I hit the dreaded error message, and although a mysql directory had been generated at /var/mysql/ no socket was generated there or anywhere else.
The problem must have been caused by the previous version of MySQL I had installed, as the solution was to do a complete uninstall (http://johnmcostaiii.net/2011/removing-mysql-osx-lion/) and then reinstall. So if you have a early version of MySQL installed and you hit this problem, this might be the solution. It worked for me.

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!

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