Could not get JDBC Connection错误

查找原因

  1. 数据库连接url是否正确?
  2. 用户名密码是否正确?
  3. MySQL是否允许远程访问?

MySQL允许远程访问方法

  1. 修改user表
mysql -u root –p
mysql>use mysql;
mysql>update user set host = '%' where user = 'root';
mysql>select host, user from user;
  1. 授权
//1.允许root用户从任何主机使用密码123456登录
mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;

//2.允许someone用户使用密码123456从10.10.50.127登录
mysql>GRANT ALL PRIVILEGES ON *.* TO 'someone'@’10.10.50.127’ IDENTIFIED BY '123456' WITH GRANT OPTION;

//3.赋予任何主机访问数据的权限
mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;

//刷新
mysql>FLUSH RIVILEGES;
    原文作者:mejhwu
    原文地址: https://www.jianshu.com/p/1c26967a878f
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞