Home > Database > Mysql Tutorial > Mysql远程访问_MySQL

Mysql远程访问_MySQL

WBOY
Release: 2016-06-01 13:45:17
Original
1154 people have browsed it

bitsCN.com

本地机器安装的数据库,本地程序可以访问,但是同事的机器却无法连接访问,发现是mysql数据库没有开启远程访问。
解决办法如下:
----------------------------------------------------------------
我的数据库mysql root用户 密码=cx,输入mysql –u root 进入mysql

允许mysql远程访问,可以使用以下三种方式:

a、改表。
Java代码 
use mysql;  
update user set host = '%' where user = 'root'; 
select host, user from user;  

b、授权。

例如,让root用户从任何主机可连接到mysql服务器。
Java代码 
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'cx' WITH GRANT OPTION; 


如果允许用户test从ip为10.40.207.17的主机连接到mysql服务器,并使用cx作为密码
Java代码 
GRANT ALL PRIVILEGES ON *.* TO 'test'@’10.40.207.17’ IDENTIFIED BY 'cx' WITH GRANT OPTION;  
LUSH RIVILEGES ; 

c:在安装mysql的机器上运行:
//进入MySQL服务器 
Java代码 
mysql -h localhost -u root   
/赋予任何主机访问数据的权限   
 
 GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION  
 //使修改生效   
 FLUSH PRIVILEGES  
//退出MySQL服务器   
  EXIT  

作者“两粒芝麻”
 

bitsCN.com
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template