Py学习  »  DATABASE

连接mysql时出现问题。找不到合适的驱动程序,用户''@'localhost'的访问被拒绝(使用密码:是)

radek.jankowski • 4 年前 • 230 次点击  

MySQL8.0.15版本
MySQL-connector-java-8.0.15接口

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;

import java.sql.*;

public class Main extends Application {

public static void main(String[] args) throws Exception {

    Statement statement = null;
    Connection connection = null;
    ResultSet resultSet = null;


    try {
        connection =
                DriverManager.getConnection("jdbc:mysql://localhost/firma?" +
                        "user=root&password=database123");

    } catch (SQLException ex) {
        // handle any errors
        System.out.println("SQLException: " + ex.getMessage());
        System.out.println("SQLState: " + ex.getSQLState());
        System.out.println("VendorError: " + ex.getErrorCode());
    }

    launch(args);
}

SQLException:找不到适合jdbc的驱动程序:mysql://localhost/firma?用户=根密码=数据库123 州:08001 供应商错误:0

SQLException:服务器时区值“rodkowoeuropejski czas stand”无法识别或表示多个时区。如果要利用时区支持,则必须配置服务器或JDBC驱动程序(通过serverTimezone配置属性)以使用更具体的时区值。 SQL状态:01S00 供应商错误:0

How can i fix the problem with timezone and SSL

DriverManager.getConnection("jdbc:mysql://localhost/firma?useLegacyDatetimeCode=false&serverTimezone=UTC?" +
                        "user=root&password=database123");

最后我得到:

SQLException:拒绝用户“@”localhost的访问(使用密码:是) 州:28000

为什么他不在这里显示用户名?

数据库存在,url中的用户和密码正确。

+------------------+-----------+
| user             | host      |
+------------------+-----------+
| mysql.infoschema | localhost |
| mysql.session    | localhost |
| mysql.sys        | localhost |
| root             | localhost |
+------------------+-----------+

从控制台我可以登录到mysql没有任何问题。

求你了,帮帮我。我的手已经掉下来了。。。

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/55417
 
230 次点击