start MySQL server from command line on Mac OS Lion

前端 未结 14 1402
名媛妹妹
名媛妹妹 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:42

    maybe your mysql-server didn't started

    you can try

    /usr/local/bin/mysql.server start

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

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

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

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

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

    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
    
    0 讨论(0)
提交回复
热议问题