---
title: " mysql数据库使root可以远程访问:"
author: "peak"
date: "2015-10-22T14:18:12Z"
tags: []
categories: ["数据库"]
slug: "mysql-root"
draft: false
lastmod: "2015-10-22T14:18:12Z"
id: 2251036
url: "https://peak.iteye.com/blog/2251036"
---

mysql数据库使root可以远程访问:

mysql -u root                                                         #进入mysql管理  
use mysql;                                                            #使用mysql数据库  
update user set host = '%' where user = 'root' and host='localhost';  #修改登陆主机为任意位置%  
grant all privileges  on \*.* to root@'%' identified by "key000000";   #赋予所有权限并设置密码  
delete from user where host != "%";                                   #删除所有其他用户，如匿名用户  
flush privileges;                                                     #刷新权限