无法从命令行访问MySQL

时间:2017-12-29 18:21:19

标签: mysql bash mamp

使用MAMP 4.2.1

我的bash个人资料:

export PATH=$PATH:/Applications/MAMP/Library/bin

事情尝试和结果:

mysql
=>ERROR 1045 (28000): Access denied for user 'jessier'@'localhost' (using password: NO)

mysql -u root -p
=>Enter password: (*mypassword)
=> ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/Applications/MAMP/tmp/mysql/mysql.sock' (2)

/Applications/MAMP/Library/bin/mysql -u root -p
=>Enter password: (*mypassword)
    => ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/Applications/MAMP/tmp/mysql/mysql.sock' (2)

sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /tmp/mysql.sock

(再次尝试使用以前的命令,相同的错误消息。重新启动终端,重新启动服务器,尝试打开和关闭服务器都没有成功.MAMP在/ phpmyadmin中正常运行。)

1 个答案:

答案 0 :(得分:0)

更新:已解决。删除了MAMP并进行了全新安装。服务器启动后,运行:

/Applications/MAMP/Library/bin/mysql --host=localhost -uroot -proot 

成功。