Can't connect to local MySQL server through socket homebrew

后端 未结 21 1892
萌比男神i
萌比男神i 2020-12-04 05:54

I recently tried installing MySQL with homebrew (brew install mysql) and when I try to run it I get the following error:

ERROR 2002 (HY00

相关标签:
21条回答
  • 2020-12-04 06:13
    1. If you are able to see "mysql stopped" when you run below command;

      brew services list
      
    2. and if you are able to start mysql with below command;

      mysql server start
      

    this means; mysql is able to start manually, but it doesn't start automatically when the operating system is started. Adding mysql to services will fix this problem. To do so, you can run below command;

    brew services start mysql
    

    After that, you may restart your operating system and try connecting to mysql to see if it started automatically. I did the same and stop receiving below error;

    ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

    I hope this helps.

    0 讨论(0)
  • 2020-12-04 06:13

    I faced the same problem on my mac and solved it, by following the following tutorials

    https://mariadb.com/resources/blog/installing-mariadb-10116-mac-os-x-homebrew

    But don't forget to kill or uninstall the old version before continuing.

    Commands:

    brew uninstall mariadb
    
    xcode-select --install
    
    ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" - See more at: https://mariadb.com/resources/blog/installing-mariadb-10116-mac-os-x-homebrew#sthash.XQoxRoJp.dpuf
    
    brew doctor
    
    brew update
    
    brew info mariadb
    
    brew install mariadb
    
    mysql_install_db
    
    mysql.server start
    
    0 讨论(0)
  • 2020-12-04 06:15

    I had some directories left from another mysql(8.0) installation, that were not removed.

    I solved this by doing the following:

    First uninstall mysql

    brew uninstall mysql@5.6
    

    Delete the folders/files that were not removed

    rm -rf /usr/local/var/mysql
    rm /usr/local/etc/my.cnf
    

    Reinstall mysql and link it

    brew install mysql@5.6
    brew link --force mysql@5.6
    

    Enable and start the service

    brew services start mysql@5.6
    
    0 讨论(0)
  • 2020-12-04 06:15

    just to complete this thread. therefore MAMP (PRO) is used pretty often

    the path here is

    /Applications/MAMP/tmp/mysql/mysql.sock
    
    0 讨论(0)
  • 2020-12-04 06:17

    I had same problem. After trying all these methods without success I did the following:

    tail -f the-mysql-or-maria-db-error-file.err
    

    in another console:

    brew services restart mariadb
    

    I saw the following error:

    "MAC HOMEBREW Crash recovery failed. Either correct the problem (if it's, for example, out of memory error) and restart, or delete tc log and start mysqld with"

    So I changed the tc.log extesion to tc.log.txt and restart mariadb

    brew services restart mariadb
    

    and done!

    0 讨论(0)
  • 2020-12-04 06:18

    You'll need to run mysql_install_db - easiest way is if you're in the install directory:

    $ cd /usr/local/Cellar/mysql/<version>/ 
    $ mysql_install_db
    

    Alternatively, you can feed mysql_install_db a basedir parameter like the following:

    $ mysql_install_db --basedir="$(brew --prefix mysql)"
    
    0 讨论(0)
提交回复
热议问题