Mysql连接出错问题

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)
--密码或用户错

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