---
title: "Mysql远程连接被拒绝"
author: "bbwang8088"
date: "2017-06-23T14:58:42Z"
tags: []
categories: ["数据库"]
slug: "mysql"
draft: false
lastmod: "2017-06-23T14:58:42Z"
id: 2381147
url: "https://bbwang8088.iteye.com/blog/2381147"
---

# 转 http://www.cnblogs.com/andy-do/archive/2013/04/06/3002541.html

# [mysql远程访问被拒绝问题](http://www.cnblogs.com/andy-do/archive/2013/04/06/3002541.html)

 

远程连接MySql数据库时:

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

远程连接被拒绝;

解决方法:

MySQL&gt; use MySQL;   
Database changed   
MySQL&gt; grant all privileges on \*.* to ‘yourUser’@'%' identified by ‘yourPassword’;   
 Query OK, 0 rows affected (0.00 sec)   
\*.\*标示所有数据库下的所有表，’\*’.\*标示数据库\*下的所有表  
MySQL&gt; grant all on \*.* to ‘yourUser’@'%' identified by ‘yourPassword’;  
Query OK, 0 rows affected (0.00 sec)   
%号出可以填写允许访问的IP地址或者主机名，%标示所有的IP  
Flush privileges;  
Query OK, 0 rows affected (0.00 sec)   
Mysql&gt; exit;