I installed MySQL on my Mac. I know how to start MySQL Server by using the MySQL.prefPane software installed in System Preference. I want to know how to start MySQL server from the command line.
What I did as the following:
I tried the MySQL server from the command line, however it generates the following error:
sh-3.2＃ / usr / local / mysql / bin / mysqld 111028 16:57:43 [Warning] set lower_case_table_names = 2, because /usr/local/mysql-5.5.17-osx10.6-x86_64/data/ file system is not case sensitive 111028 16:57:43 [Error] Fatal error: Please read the "Security" section of the manual to learn how to run mysqld as root! 111028 16:57:43 [Error] is aborting 111028 16:57:43 [Note] /usr / local / mysql / bin / mysqld: shutdown completed
After I did some research, I find the reason here: http://dev.mysql.com/doc/refman/5.5/en/changing- Mysql-user.html
The soultion to how to start MySQL from the command line as the following.
sudo /Library/StartupItems/MySQLCOM/MySQLCOM start sudo /Library/StartupItems/MySQLCOM/MySQLCOM stop
Create an alias in .bash_profile, it’s more simply to use the command to start or stop MySQL Server.
alias start_mysql="/Library/StartupItems/MySQLCOM/MySQLCOM start" alias stop_mysql="/Library/StartupItems/MySQLCOM/MySQLCOM stop"
The I tried to run the following security mode as root.
If you are still encounted the problem, you should to read this article: mysql5.58 unstart server in mac to find solutions.
My MySQL is installed by the homebrew command on OS X ElCaptain.
It means that I ran
sudo chown -R $(whoami):admin /usr/local
and to run this command:
brew update mysql.server start
Now, the MySQL server is running.
More solutions to start MySQL from the command line on Mac OS.
1.Some friends said that this solution works very well for Mac Sierra OS, you can try it.
sudo /usr/local/bin/mysql.server start Starting MySQL SUCCESS!
2.Try the command:
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)
It’s better to add these to the bash startup script:
export MYSQL_HOME=/usr/local/mysql alias start_mysql='sudo $MYSQL_HOME/bin/mysqld_safe &' alias stop_mysql='sudo $MYSQL_HOME/bin/mysqladmin shutdown'