第一次使用mysql_windows第一次使用mysql问题

本文记录了解决MySQL错误1130(Host 'localhost' 不允许连接到此MySQL服务器)以及无法连接到localhost的步骤。通过更新MySQL用户host设置为%,刷新权限,并检查端口冲突,最终成功建立连接。
摘要由CSDN通过智能技术生成

错误问题:

--------------------------------------------------

Mysql ERROR 1130: Host "localhost" is not allowed to connect to this MySQL server...

---------------------------------------------------

解决方案:

D:\APMServ5.2.6\Mysql Server5.0\bin>mysql

ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)

D:\APMServ5.2.6\Mysql Server5.0\bin>mysqld-nt

D:\APMServ5.2.6\Mysql Server5.0\bin>mysql -u root -p

Enter password: ******

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 4

Server version: 5.0.87-community-nt MySQL Community Edition (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> use mysql;

Database changed

mysql> update user set host='%'where user ='root';

Query OK, 1 row affected (0.00 sec)

Rows matched: 1  Changed: 1  Warnings: 0

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

mysql>

==================

备用:

:\mysql\bin>mysql

ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)

服务没有启动D:\mysql\bin>mysqld-nt

D:\mysql\bin>mysql

ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)

依然,被郁闷了! 怎么回事,端口被占用?D:\mysql\bin>netstat -a

Active Connections

Proto Local Address Foreign Address State

TCP gszhangxudong:epmap gszhangxudong.home.langchao.com:0 LISTENING

TCP gszhangxudong:microsoft-ds gszhangxudong.home.langchao.com:0 LISTENING

TCP gszhangxudong:1041 gszhangxudong.home.langchao.com:0 LISTENING

TCP gszhangxudong:2809 gszhangxudong.home.langchao.com:0 LISTENING

TCP gszhangxudong:3077 gszhangxudong.home.langchao.com:0 LISTENING

TCP gszhangxudong:3389 gszhangxudong.home.langchao.com:0 LISTENING

TCP gszhangxudong:3992 gszhangxudong.home.langchao.com:0 LISTENING

TCP gszhangxudong:4047 gszhangxudong.home.langchao.com:0 LISTENING

TCP gszhangxudong:8880 gszhangxudong.home.langchao.com:0 LISTENING

TCP gszhangxudong:9043 gszhangxudong.home.langchao.com:0 LISTENING

TCP gszhangxudong:9080 gszhangxudong.home.langchao.com:0 LISTENING

TCP gszhangxudong:9090 gszhangxudong.home.langchao.com:0 LISTENING

TCP gszhangxudong:9443 gszhangxudong.home.langchao.com:0 LISTENING

TCP gszhangxudong:netbios-ssn gszhangxudong.home.langchao.com:0 LISTENING

TCP gszhangxudong:1044 202.104.11.94:http CLOSE_WAIT

TCP gszhangxudong:1173 220.90.198.182:http CLOSE_WAIT

TCP gszhangxudong:1238 202.101.42.187:http CLOSE_WAIT

TCP gszhangxudong:1430 baym-cs224.msgr.hotmail.com:1863 ESTABLISHED

TCP gszhangxudong:3999 10.100.1.126:50001 ESTABLISHED

TCP gszhangxudong:4000 10.100.1.126:50001 ESTABLISHED

TCP gszhangxudong:4124 10.100.1.126:50001 ESTABLISHED

TCP gszhangxudong:4125 10.100.1.126:50001 ESTABLISHED

UDP gszhangxudong:microsoft-ds *:*

UDP gszhangxudong:isakmp *:*

UDP gszhangxudong:1025 *:*

UDP gszhangxudong:1026 *:*

UDP gszhangxudong:1440 *:*

UDP gszhangxudong:2684 *:*

UDP gszhangxudong:2822 *:*

UDP gszhangxudong:3643 *:*

UDP gszhangxudong:4500 *:*

UDP gszhangxudong:discard *:*

UDP gszhangxudong:ntp *:*

UDP gszhangxudong:netbios-ns *:*

UDP gszhangxudong:netbios-dgm *:*

UDP gszhangxudong:65183 *:*

UDP gszhangxudong:ntp *:*

UDP gszhangxudong:1027 *:*

UDP gszhangxudong:1042 *:*

UDP gszhangxudong:1053 *:*

UDP gszhangxudong:1431 *:*

UDP gszhangxudong:2615 *:*

UDP gszhangxudong:4708 *:*

难道端口被封?偶的windows自带的防火墙已经关了,那就是防毒软件了。MacFee,嘿嘿,打开,看他的策略,没有问题啊,3306没有被拦截....

怎么回事啊?

直接到事件察看器,看到了MySql的红红的叉号!错误。。。。

第一个:Aborting

For more information, see Help and Support Center at http://www.mysql.com.

第二个:

Can't find messagefile 'C:\mysql\share\english\errmsg.sys'

For more information, see Help and Support Center at http://www.mysql.com.

服了,我也没有安装到c:\盘啊,你怎么找c:\盘么,非得逼我重新拷到c:\ 么?

难道是默认的配置文件?

直接在d:\mysql文件加下搜索文件中含有"c:\"字符的文件,找到两个:config-os2.h

mytest.c

config-os2.h这个文件里面有

#define DEFAULT_MYSQL_HOME "c:\\mysql"

#define DEFAULT_BASEDIR "c:\\"

#define DEFAULT_CHARSET_HOME "c:/mysql/"

试着更改到d:\\mysql

嘿嘿 重新启动服务,一样......

哭,应该不是这里的问题,这仅仅是一个config-win.h头文件,也没有编译也没有连接,晕死,能起作用么?傻了。

想了一下,难道是因为以前俺安装mysql在c:\的缘故?注册表的信息还是指向c:\mysql?

者有可能,更在注册表吧!那个键在哪儿?

偶搜了注册表半天,找不到任何mysql连到c:\mysql的信息,得,还是先把服务给卸了吧。

到网上搜了一个ViewService的软件,把那个mysql 和 mysqlManager给卸载了。

然后:D:\mysql\bin>mysqld-nt.exe

D:\mysql\bin>mysql

ERROR 1045 (28000): Access denied for user 'ODBC'@'localhost' (using password: NO)

到网上搜索了一下,晕,这下成了。。。。D:\mysql\bin>mysql -u root -p

Enter password:

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 4 to server version: 5.0.20-nt

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

嘿嘿,搞定。。。。

官方的解释:

Was your username ODBC? Because it looks like you specified no username and password to me, as the ODBC user is the default on Windows when you do not specify a username when connecting to MySQL

总结一下:

看日志(如果有的话)

看服务

看时间察看器

last is think, thinkD:\mysql\bin>mysql -u root

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 6 to server version: 5.0.20-nt

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> show databases;

+--------------------+

| Database |

+--------------------+

| information_schema |

| mysql |

| test |

+--------------------+

3 rows in set (0.00 sec)

mysql 5 竟然有了information_schema,嘿嘿....

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值