我刚刚在 OSX 10.6.6 上的 MySQL 站点上从 DMG 安装了 MySQL 服务器和启动工具。我重新启动了计算机,但似乎无法连接到其插槽。
$ /usr/local/mysql/bin/mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
我尝试启动服务器
$ sudo /usr/local/mysql/bin/mysqld_safe &
[2] 917
但我还是
$ /usr/local/mysql/bin/mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
我似乎找不到套接字文件
$ ls /tmp/mysql*
ls: /tmp/mysql*: No such file or directory
$ ls /var/lib/mysql*
ls: /var/lib/mysql*: No such file or directory
答案1
您必须启动服务器并添加 root 用户。
启动服务器:
sudo /usr/local/mysql/support-files/mysql.server start
,或者
sudo /usr/local/mysql/bin/mysqld_safe --user=mysql &
,或者
sudo /Library/StartupItems/MySQLCOM/MySQLCOM start
添加root用户:
/usr/local/mysql/bin/mysqladmin -u root password your_password
答案2
像这样启动你的 Mysql-Server:
服务 mysql 启动