[mysql]ERROR 2002 (HY000): Can't connect to local MySQL server through socket 'tmpmysql.sock'

xiaoxiao2021-02-28  21

正确的安装步骤:

1. 执行:

$ brew install mysql

2. 在 /usr/local/etc/ 下创建或修改 my.cnf,示例:

[client] port = 3306 socket = /tmp/mysql.sock default-character-set = utf8 [mysqld] collation-server = utf8_unicode_ci character-set-server = utf8 init-connect ='SET NAMES utf8' max_allowed_packet = 64M bind-address = 127.0.0.1 port = 3306 socket = /tmp/mysql.sock innodb_file_per_table=1 [mysqld_safe] timezone = '+0:00'

3. 赞安装完 mysql 后,他会提示你 init database,并提供下面这两句让你执行,很可能你没执行这两句

$ unset TMPDIR $ mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp

4. 然后就可以指向 mysql.server start 来启动了,为了安全,你还可以执行安全设置向导,根据提示一步一步配置

$ mysql_secure_installation

原先遇到类似问题剪辑的内容,出处忘了

转载请注明原文地址: https://www.6miu.com/read-2800125.html

最新回复(0)