Home > Database > Mysql Tutorial > mysql远程无法登陆解决办法_MySQL

mysql远程无法登陆解决办法_MySQL

WBOY
Release: 2016-06-01 12:59:02
Original
1073 people have browsed it

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

 

ALL PRIVILEGES表示所有的权限

myuser表示你要新增的mysql用户

%表示可以从所有的ip地址访问这个mysql数据库,也可以指定ip地址,比如root的默认ip地址是localhost和127.0.0.1.

所以root默认只能在mysql的安装机子上连接。

mypassword表示你要新增的用户的密码

例子:

假如现在我的mysql是安装在118.114.245.44上面

GRANT ALL PRIVILEGES ON *.* TO 'dade'@'118.114.245.55'IDENTIFIED BY '123456' WITH GRANT OPTION;

那么只有在118.114.245.55这个机子上才可以通过

用户名:dade

密码:123456

url:118.114.245.44

来访问数据库,及时在数据库的安装机子118.114.245.44也是不可以访问数据库的。

 

同理,默认的root用户是这样创建的:

GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost'IDENTIFIED BY 'root' WITH GRANT OPTION;

GRANT ALL PRIVILEGES ON *.* TO 'root'@'127.0.0.1'IDENTIFIED BY 'root' WITH GRANT OPTION;

所以只能通过本机的localhost和127.0.0.1才可以访问数据库!

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