ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)
现象:
本机mysql已经起来,用Navicat for MySQL也能连接上,但是在命令行(CMD)中,mysql -u root -p 密码时报如上错误.(密码是正确的),
操作如下:
1,检查mysql服务是否存在
c:\>sc query mysql
SERVICE_NAME: mysql
TYPE : 10 WIN32_OWN_PROCESS
STATE : 4 RUNNING
(STOPPABLE, PAUSABLE, ACCEPTS_SHUTDOWN)
WIN32_EXIT_CODE : 0 (0x0)
SERVICE_EXIT_CODE : 0 (0x0)
CHECKPOINT : 0x0
WAIT_HINT : 0x0
2,检查mysql是否起来
c:\>net start mysql
请求服务已经启动
3,链接数据库>mysql -uroot -p
Enter password: ******
ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)
解决问题:
C:\Program Files\MySQL\MySQL Server 5.1\bin>mysql -u root -p
原因: 系统变量中没有注册相关路径,所以在c:\>无法链接上,在bin>下就ok了。
参考资料[1]
ERROR 2003: Can't connect to MySQL server on 'localhost' (10061)解决方法
http://www.blogjava.net/bcims/archive/2007/07/03/127939.html