Chinaunix首页 | 论坛 | 博客
  • 博客访问: 278905
  • 博文数量: 78
  • 博客积分: 3018
  • 博客等级: 少校
  • 技术积分: 950
  • 用 户 组: 普通用户
  • 注册时间: 2006-04-07 02:33
文章分类

全部博文(78)

文章存档

2013年(1)

2012年(19)

2011年(45)

2008年(13)

分类: Mysql/postgreSQL

2011-03-21 09:06:07

Mysql默认不允许从远程访问,解决方法:
  1、改表法。可能是你的帐号不允许从远程登陆,只能先登入mysql后,更改 "mysql" 数据库里的 "user" 表里的 "host" 项,从"localhost"改称"%"
引用
[root@meguro etc]# /usr/local/mysql/bin/mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 110
Server version: 5.0.51b-log Source distribution

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

      mysql>
      mysql>use mysql;
  mysql>update user set host = '%' where user = 'root';
  mysql>select host, user from user;
      mysql>flush privileges;

  2、授权法。例如,你想root从任何主机连接到mysql服务器的话。
  GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'IDENTIFIED BY '123456' WITH GRANT OPTION;
  如果你想允许用户root从ip为192.168.1.6的主机连接到mysql服务器,
  GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.1.3'IDENTIFIED BY '123456' WITH GRANT OPTION;
 
*MySQL 连接远程数据库(192.168.8.209),端口“3306”,用户名为“root”,密码“123456”
 
#mysql -h 192.168.8.209 -P 3306 -uroot -p123456
阅读(404) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~