mysqlmacoscommand-lineosx-lion

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


Solution

  • 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'