资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

mysql怎么让别人访问,连接别人的mysql

如何让mysql数据库允许被远程连接访问?

第一:更改 “mysql” 数据库里的 “user” 表里的 “host” 项,从”localhost”改称'%'。 \x0d\x0a或者新加条记录,“host” 项为要访问的ip地址,并授权。重启mysql服务。 \x0d\x0a第二:在系统防火墙添加例外端口:3306,并允许例外。 \x0d\x0a\x0d\x0a错误提示: \x0d\x0aERROR 1130: Host '192.168.1.3' is not allowed to connect to this MySQL server \x0d\x0a的解决方法: \x0d\x0a1。改表法。可能是你的帐号不允许从远程登陆,只能在localhost。这个时候只要在localhost的那台电脑,登入mysql后,更改 "mysql" 数据库里的 "user" 表里的 "host" 项,从"localhost"改称"%" \x0d\x0a1.mysql -u root -pvmware\x0d\x0amysqluse mysql;\x0d\x0amysqlupdate user set host = '%' where user = 'root';\x0d\x0amysqlselect host, user from user; \x0d\x0a\x0d\x0a2. 授权法。例如,你想myuser使用mypassword从任何主机连接到mysql服务器的话。 \x0d\x0a\x0d\x0aGRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION; \x0d\x0a如果你想允许用户myuser从ip为192.168.1.3的主机连接到mysql服务器,并使用mypassword作为密码 \x0d\x0aGRANT ALL PRIVILEGES ON *.* TO 'myuser'@'192.168.1.3' IDENTIFIED BY 'mypassword' WITH GRANT OPTION; \x0d\x0a\x0d\x0a3.在window自带的防火墙里的例外添加3306端口 \x0d\x0a\x0d\x0a总结: \x0d\x0amysql -u root -p \x0d\x0amysqluse mysql; \x0d\x0amysqlselect 'host' from user where user='root'; \x0d\x0amysqlupdate user set host = '%' where user ='root'; \x0d\x0amysqlflush privileges; \x0d\x0amysqlselect 'host' from user where user='root'; \x0d\x0a第一句是以权限用户root登录 \x0d\x0a第二句:选择mysql库 \x0d\x0a第三句:查看mysql库中的user表的host值(即可进行连接访问的主机/IP名称) \x0d\x0a第四句:修改host值(以通配符%的内容增加主机/IP地址),当然也可以直接增加IP地址 \x0d\x0a第五句:刷新MySQL的系统权限相关表 \x0d\x0a第六句:再重新查看user表时,有修改。。 \x0d\x0a重起mysql服务即可完成。

网站建设哪家好,找创新互联建站!专注于网页设计、网站建设、微信开发、微信小程序定制开发、集团企业网站建设等服务项目。为回馈新老客户创新互联还提供了市南免费建站欢迎大家使用!

mysql怎么让别人远程访问

第一:更改 “mysql” 数据库里的 “user” 表里的 “host” 项,从”localhost”改称'%'。

或者新加条记录,“host” 项为要访问的ip地址,并授权。重启mysql服务。

第二:在系统防火墙添加例外端口:3306,并允许例外。

错误提示:

ERROR 1130: Host '192.168.1.3' is not allowed to connect to this MySQL server

的解决方法:

1。改表法。可能是你的帐号不允许从远程登陆,只能在localhost。这个时候只要在localhost的那台电脑,登入mysql后,更改 "mysql" 数据库里的 "user" 表里的 "host" 项,从"localhost"改称"%"

1.mysql -u root -pvmware

mysqluse mysql;

mysqlupdate user set host = '%' where user = 'root';

mysqlselect host, user from user;

2. 授权法。例如,你想myuser使用mypassword从任何主机连接到mysql服务器的话。

GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;

如果你想允许用户myuser从ip为192.168.1.3的主机连接到mysql服务器,并使用mypassword作为密码

GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'192.168.1.3' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;

3.在window自带的防火墙里的例外添加3306端口

总结:

mysql -u root -p

mysqluse mysql;

mysqlselect 'host' from user where user='root';

mysqlupdate user set host = '%' where user ='root';

mysqlflush privileges;

mysqlselect 'host' from user where user='root';

第一句是以权限用户root登录

第二句:选择mysql库

第三句:查看mysql库中的user表的host值(即可进行连接访问的主机/IP名称)

第四句:修改host值(以通配符%的内容增加主机/IP地址),当然也可以直接增加IP地址

第五句:刷新MySQL的系统权限相关表

第六句:再重新查看user表时,有修改。。

重起mysql服务即可完成。

如何让别人远程连接到自己的MySql数据库

MYSQL要想让别人远程访问自己的数据库,必须让mysql库中user表的host字段为%,接受远程控制请求 ,可以进入mysqluser mysql;

mysqlupdate user set host="%" where user="root" and host="localhost";这样别人就可以通过 mysql -h xxx.xxx.xxx.xxx(你电脑的IP) -u root -p密码 进行连接并操作数据库了。

怎么设置MySQL就能让别人访问本机的数据库了?

找到MySQL配置文件,搜索“bind-address”,找到这一行:

bind-address = 127.0.0.1 在前面加一个#,注释掉这一行,保存,重启MySQL。

再通过远程访问就可以了,telnet可以发现端口也打开了。

例配置:

1. 确保skip-networking被删除或者屏蔽,否则不支持TCP/IP 访问

2. 增加行bind-address = 65.55.55.2,替代65.55.55.2 为你的服务器地址

修改后,配置为:

[mysqld]

user = mysql

pid-file = /var/run/mysqld/mysqld.pid

socket = /var/run/mysqld/mysqld.sock

port = 3306

basedir = /usr

datadir = /var/lib/mysql

tmpdir = /tmp

language = /usr/share/mysql/English

bind-address = 65.55.55.2

# skip-networking

保存并关闭配置文件

重启mysql服务器:# /etc/init.d/mysql restart

如果上面办法没有用我们可以通用mysql命令模式进行设置:

可能是你的帐号不允许从远程登陆,只能在localhost。这个时候只要在localhost的那台电脑,登入mysql后,更改 "mysql" 数据库里的 "user" 表里的 "host" 项,从"localhost"改称"%"   

CODE:mysql -u root -p123

mysqluse mysql;

mysqlupdate user set host = '%' where user = 'root';

mysqlselect host, user from user;

如何让mysql数据库允许被远程连接访问

一、连接远程数据库:

1、显示密码

如:MySQL 连接远程数据库(192.168.5.116),端口“3306”,用户名为“root”,密码“123456”

C:/mysql -h 192.168.5.116 -P 3306 -u root -p123456

2、隐藏密码

如:MySQL 连接本地数据库,用户名为“root”,

C:/mysql -h localhost -u root -p

Enter password:

二、配置mysql允许远程链接

默认情况下,mysql帐号不允许从远程登陆,只能在localhost登录。本文提供了二种方法设置mysql可以通过远程主机进行连接。

一、改表法

在localhost登入mysql后,更改 "mysql" 数据库里的 "user" 表里的 "host" 项,将"localhost"改称"%"

例如:

#mysql -u root -p

Enter password:

……

mysql

mysqlupdate user set host = '%' where user = 'root';

mysqlselect host, user from user;

二、授权法

例如: 你想myuser使用mypassword(密码)从任何主机连接到mysql服务器的话。

mysqlGRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%'IDENTIFIED BY 'mypassword' WITH GRANT OPTION;

如果你想允许用户myuser从ip为192.168.1.6的主机连接到mysql服务器,并使用mypassword作为密码

mysqlGRANT ALL PRIVILEGES ON *.* TO 'myuser'@'192.168.1.3'IDENTIFIED BY

'mypassword' WITH GRANT OPTION;

mysqlFLUSH PRIVILEGES

使修改生效,就可以了

常见问题:

1、在采用法二授权法之后,无法在本地登录mysql(如:#mysql -u root -p -h 192.168.5.116

Enter password:

ERROR 1045 (28000): Access denied for user 'root'@'loadb116' (using password: YES)

上例中loadb116是主机名.

解决方法:

1、这时可以使用:mysql -u root -p 登录,进入到mysql后。

mysql grant all privileges on *.* to 'root'@'loadb116'

identified by '123456' with grant option;

Query OK, 0 rows affected (0.00 sec)

mysql flush privileges;

Query OK, 0 rows affected (0.00 sec)

2、在本地使用ip地址登录

# mysql -u root -p -h 192.168.5.116

Enter password:

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

Your MySQL connection id is 60

Server version: 5.1.45 MySQL Community Server (GPL)

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

mysql


当前文章:mysql怎么让别人访问,连接别人的mysql
链接分享:http://cdkjz.cn/article/hsjscp.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

业务热线:400-028-6601 / 大客户专线   成都:13518219792   座机:028-86922220