start MySQL server from command line on Mac OS Lio

2019-01-20 20:54发布

I installed mySQL for my Mac. Beside starting the SQL server with mySQL.prefPane tool installed in System Preference, I want to know the instruction to start from command-line. I do as follow:

After

su root

I start the mySQL server by command-line, it produce 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

Please help me!

EDIT:

The reason is here: http://dev.mysql.com/doc/refman/5.5/en/changing-mysql-user.html

A solution is described in the xdazz's answer below.

12条回答
戒情不戒烟
2楼-- · 2019-01-20 21:40

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

查看更多
干净又极端
3楼-- · 2019-01-20 21:41

For me this solution worked on mac Sierra OS:

sudo /usr/local/bin/mysql.server start
Starting MySQL
SUCCESS!
查看更多
倾城 Initia
4楼-- · 2019-01-20 21:42

Simply:

mysql.server start

mysql.server stop

mysql.server restart

查看更多
小情绪 Triste *
5楼-- · 2019-01-20 21:45
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

查看更多
何必那么认真
6楼-- · 2019-01-20 21:47

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' 
查看更多
迷人小祖宗
7楼-- · 2019-01-20 21:48
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

查看更多
登录 后发表回答