---
title: "CentOS上开启MySQL远程访问权限"
author: "CunningFox"
date: "2013-01-28T14:34:28Z"
tags: []
categories: ["数据库"]
slug: "centos-mysql"
draft: false
lastmod: "2013-01-25T21:50:49Z"
id: 1775935
url: "https://cunningfox.iteye.com/blog/1775935"
---

在CentOS上安装完MySQL后，默认不开始远程访问控制。可以进行如下设定开启。

登录MySQL：
mysql -uroot -p

如需修改密码，第一次：
mysqladmin -u root password NEWPASSWORD
已设置过：
mysqladmin -u root -p 'oldpassword' password newpassword

执行以下命令开启远程访问限制
grant all privileges on *.* to 'root'@'192.168.0.1' identified by 'password' with grant option;
flush privileges;
exit

上面的是开启的IP 192.168.0.1的，如要开启所有的，用%代替IP