新安装mysql 第三方工具连接不上问题


Mysql从client连接server连不上的问题
 
公司要用Mysql做一个測试,開始在自己的本地建一个Mysql 数据库自己本地的程序再连上去,没有遇到过连接不上的问题。
这次数据库在server上。从本地client连接就是被拒绝。 
 
报的错误为 
ERROR 1130: Host ’192.168.5.3’ is not allowed to connect to this MySQL server 
  www.2cto.com  
查过资料后发现这个问题,一般都会遇到。My sql数据库跟其它数据库不一样,须要设置权限能够控制哪台机器能訪问数据库。能訪问哪些表。

 

所以就要登上server。 
C:\Documents and Settings\Administrator> mysql -h localhost -u root -p 
Enter password: *** 
Welcome to the MySQL monitor.  Commands end with ; or \g. 
Your MySQL connection id is 5 
Server version: 5.1.43-community MySQL Community Server (GPL) 
 
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. 
  www.2cto.com  
mysql> grant all privileges on *.* to root@'%' identified by '123' with grant 
    -> option; 
Query OK, 0 rows affected (0.00 sec) 
意思就是将server上的全部资源都给root用户权限,%代表来自不同的IP 
这里须要注意一下要把password也要带上。通过password123登录。

 

mysql> FLUSH PRIVILEGES; 
Query OK, 0 rows affected (0.00 sec) 
最后要刷新下权限。

 

 
这样就从本地192.168.5.3这个IP的client连接到server上了


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM