Navicat for mysql 远程链接 mySql数据库1006一、1045错误问题

远程使用Navicat for mysql 客户端软件链接 mySql数据时,链接出现 2003-Can’t connect to MySQL on ’192.168.1.2’(10061)错误时,是因为MySQL不许许远程链接。

修改方法以下:mysql

    1:在服务端MySQL文件夹下找到my.ini文件。修改bind-address=127.0.0.1 为 bind-address=0.0.0.0 (在MySQL 5的my.ini中未发现此项)web

    2:从新启动MySQL服务。sql

测试链接状况:数据库

    若是没有给远程登陆用户添加全部机器都能访问的权限,将会出现“1045-Access denied for user root@IT(using password:NO)”,这代表须要添加权限;服务器

    添加命令以下:ide

    1)grant all on *.* to 用户名@"%" identified by "密码"; 测试

    2)flush privileges;server


完成以上步骤,就能够远程访问MySQL数据库了。接口

 

grant 权限1,权限2,…权限n on 数据库名称.表名称 to 用户名@用户地址 identified by ‘链接口令’;

权限1,权限2,…权限n表明select,insert,update,delete,create,drop,index,alter,grant,references,reload,shutdown,process,file等14个权限。
当权限1,权限2,…权限n被all privileges或者all代替,表示赋予用户所有权限。
当数据库名称.表名称被*.*代替,表示赋予用户操做服务器上全部数据库全部表的权限。
用户地址能够是localhost,也能够是ip地址、机器名字、域名。也能够用’%'表示从任何地址链接。
‘链接口令’不能为空,不然建立失败。



例如:
mysql>grant select,insert,update,delete,create,drop on vtdc.employee to joe@10.163.225.87 identified by ‘123′;
给来自10.163.225.87的用户joe分配可对数据库vtdc的employee表进行select,insert,update,delete,create,drop等操做的权限,并设定口令为123。

mysql>grant all privileges on vtdc.* to joe@10.163.225.87 identified by ‘123′;
给来自10.163.225.87的用户joe分配可对数据库vtdc全部表进行全部操做的权限,并设定口令为123。

mysql>grant all privileges on *.* to joe@10.163.225.87 identified by ‘123′;
给来自10.163.225.87的用户joe分配可对全部数据库的全部表进行全部操做的权限,并设定口令为123。

mysql>grant all privileges on *.* to joe@localhost identified by ‘123′;
给本机用户joe分配可对全部数据库的全部表进行全部操做的权限,并设定口令为123。ip

mysql添加用户方法

创建数据库gamesp

create database gamesp;

添加用户

grant all on 数据库名.* to 用户名@localhost identified by '密码';


grant all on gamesp.* to newuser@localhost identified by 'password';

添加一个远程用户,名为username密码为password
GRANT ALL PRIVILEGES ON *.* TO username@"%" IDENTIFIED BY 'password'

说明:

(1)grant all 赋予全部的权限

(2)gamesp.* 数据库 gamesp 中全部的表

(3)newuser 用户名

(4)@localhost 在本地电脑上的 mysql server 服务器

(5)identfified by 'password' 设置密码

删除用户
use mysql
mysql>Delete FROM user Where User="xxxxx" and Host="localhost";
mysql>flush privileges;

修改密码 mysqladmin -uroot -plk317921web password "111111"