MySQL远程连接不上!!

Web、Mail、Ftp、DNS、Proxy、VPN、Samba、LDAP 等基础网络服务
回复
头像
0xff
帖子: 415
注册时间: 2008-08-12 14:24
联系:

MySQL远程连接不上!!

#1

帖子 0xff » 2009-09-03 10:58

Ubuntu804上自带的MySQL,执行了mysql_install_db,我自己的表也已经创建完毕

本地访问可以:

root@ubuntu804:~# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 5.0.51a-3ubuntu5.4 (Ubuntu)

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

设置了远程访问权限:
mysql> grant all PRIVILEGES on nw.* to root@'%' identified by 'root';
Query OK, 0 rows affected (0.04 sec)

查看数据库:
mysql> use nw
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> show tables;
+-----------------+
| Tables_in_nw |
+-----------------+
| t_activity_host |
| t_origin_log |
+-----------------+
2 rows in set (0.00 sec)

mysql> select * from t_origin_log;
Empty set (0.00 sec)
可以看到表已经创建成功了,但还没有记录。

root@ubuntu804:~# netstat -an |grep 3306
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN
本地端口也在监听

root@ubuntu804:~# ufw status
Firewall not loaded
本地防火墙未打开

本地telnet连接3306也可以连接

但是
root@ubuntu804:~# /usr/bin/mysqladmin -u root password 'root'
/usr/bin/mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: NO)'

并且远程访问一律失败,远程telnet3306也无法连接
C:\>telnet 192.168.14.199 3306
正在连接到192.168.14.199...不能打开到主机的连接, 在端口 3306: 连接失败

root@ubuntu804:~# /usr/bin/mysqladmin -u root password 'root'
/usr/bin/mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: NO)'

请问谁知道这是咋回事啊
头像
木泥黑
帖子: 1339
注册时间: 2008-10-18 12:41

Re: MySQL远程连接不上!!

#2

帖子 木泥黑 » 2009-09-03 14:23

格式是

mysql -u root -p
上次由 木泥黑 在 2010-02-25 9:59,总共编辑 1 次。
头像
0xff
帖子: 415
注册时间: 2008-08-12 14:24
联系:

Re: MySQL远程连接不上!!

#3

帖子 0xff » 2009-09-03 15:35

执行了,什么效果都没有,执行后debian.cnf内容不变,
远程还是连不上.
davidchenbin
帖子: 62
注册时间: 2008-08-22 20:04

Re: MySQL远程连接不上!!

#4

帖子 davidchenbin » 2009-09-17 1:54

SELECT Host, User FROM mysql.user

查看root用户是否具有远程访问权限,mysql默认是不具有的
liyankx
帖子: 48
注册时间: 2008-07-25 7:40

Re: MySQL远程连接不上!!

#5

帖子 liyankx » 2009-09-18 10:23

我也是上午才搞通的
首先
mysql>use mysql;
mysql>update user set Host = '%' where User = 'username';
然后
打开 /etc/mysql/my.cnf 文件,找到 bind-address = 127.0.0.1 修改为 bind-address = 0.0.0.0
重启mysql : sudo /etc/init.d/mysql restart
就好了,我在windows XP下用Navicat for mysql 一下就连上了。
xuehuihe.java
帖子: 1
注册时间: 2010-07-14 17:08

Re: MySQL远程连接不上!!

#6

帖子 xuehuihe.java » 2010-07-21 10:56

按楼上的OK,谢谢!
iamkris
帖子: 26
注册时间: 2010-03-15 23:05

Re: MySQL远程连接不上!!

#7

帖子 iamkris » 2010-11-16 22:48

谢谢 5楼啊 弄好了
回复