码迷,mamicode.com
首页 > 数据库 > 详细

Mysql连接出错问题

时间:2015-12-11 12:49:16      阅读:201      评论:0      收藏:0      [点我收藏+]

标签:

1.java 提示:java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

处理:导入mysql-connector-java-5.1.7-bin.jar

import java.sql.Connection;
import java.sql.DriverManager;

try{
   Connection con = null;
   Class.forName("com.mysql.jdbc.Driver");
   con=DriverManager.getConnection("jdbc:mysql://10.0.1.1/ssworkplat","root","1111");   
      System.out.println("ok");
  }
  catch(Exception e){
   e.printStackTrace();
  }

 

2.无法连接远程服务器,message from server: "Host ‘14.119.154.27‘ is not allowed to connect to this MySQL server

处理:数据库管理

a.所有地址可以登录

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

b,特定IP

GRANT ALL PRIVILEGES ON *.* TO ‘myuser‘@‘192.168.1.188‘ IDENTIFIED BY ‘mypassword‘ WITH GRANT OPTION;
FLUSH   PRIVILEGES;

3.
java.sql.SQLException: Access denied for user ‘root‘@‘14.119.154.27‘ (using password: YES)
--密码或用户错

Mysql连接出错问题

标签:

原文地址:http://www.cnblogs.com/realhope/p/5038388.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!