start MySQL server from command line on Mac OS Lion

前端 未结 14 1401
名媛妹妹
名媛妹妹 2020-11-30 16:22

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-li

相关标签:
14条回答
  • 2020-11-30 16:35
    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

    0 讨论(0)
  • 2020-11-30 16:35

    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/

    0 讨论(0)
  • 2020-11-30 16:37

    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 
    
    0 讨论(0)
  • 2020-11-30 16:37

    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.

    0 讨论(0)
  • 2020-11-30 16:38

    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

    0 讨论(0)
  • 2020-11-30 16:39

    For me this solution worked on mac Sierra OS:

    sudo /usr/local/bin/mysql.server start
    Starting MySQL
    SUCCESS!
    
    0 讨论(0)
提交回复
热议问题