Home > Database > Mysql Tutorial > body text

mysql开启远程登录方法介绍

WBOY
Release: 2016-06-07 17:52:30
Original
1003 people have browsed it

下面介绍两种快速mysql开启远程登录方法 有需要学习的朋友可参考一下下。

 代码如下 复制代码

mysql -u root -p
mysql> use mysql;
mysql> grant all privileges  on *.* to root@’%’ identified by “root”;
mysql> select host,user,password from user;

+————–+——+——————————————-+
| host         | user | password                                  |
+————–+——+——————————————-+
| localhost    | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
| 192.168.1.12 | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
| %            | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
+————–+——+——————————————-+
3 rows in set (0.00 sec)

mysql> flush privileges;

授权法:

例如,你想myuser使用mypassword从任何主机连接到mysql服务器的话。

 代码如下 复制代码

mysql> GRANT ALL PRIVILEGES ON *.* TO IDENTIFIED BY ‘mypassword’ WITH GRANT OPTION;

如果你想允许用户myuser从ip为192.168.1.6的主机连接到mysql服务器,并使用mypassword作为密码

 代码如下 复制代码

mysql> GRANT ALL PRIVILEGES ON *.* TO ‘myuser’@'192.168.1.3′ IDENTIFIED BY 'mypassword’ WITH GRANT OPTION;


注意:
1、格式:grant 权限 on 数据库名.表名 to 用户@登录主机 identified by “用户密码”;
2、是新增ROOT不是修改,如果把localhost改为%,那么本地就无法通过localhost连接mysql了;
3、刷新MySQL的系统权限相关表 flush privileges;

更多相关开启mysql远程连接可参考:http://www.111cn.net/database/mysql/34989.htm

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!