无法在 NetBeans IDE 中建立与 MySQL 的连接 [英] Cannot establish a connection to MySQL in NetBeans IDE

查看:42
本文介绍了无法在 NetBeans IDE 中建立与 MySQL 的连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用 Hibernate 创建一个新的 Web 项目时,我打开 New Connection Wizard,选择 MySQL (Connector/J driver) 选项(连接器 jar 出现在 Driver Files 列表中),我按下 Next 按钮,设置 Host: 127.0.0.1,端口:3306,数据库名,用户名:root,空白密码字段.然后我得到 无法使用 com.mysql.jdbc.Driver 建立与 jdbc:mysql://127.0.0.1:3306/databasename 的连接(用户'root'@'localhost'的访问被拒绝(使用密码:YES))

When I create a new web project with Hibernate, I open New Connection Wizard, choose MySQL (Connector/J driver) option (connector jar appears in the Driver Files list), I press the Next button, set Host: 127.0.0.1, Port: 3306, databasename, User Name: root, blank password field. Then I get cannot establish a connection to jdbc:mysql://127.0.0.1:3306/databasename using com.mysql.jdbc.Driver (Access denied for user 'root'@'localhost' (using password: YES))

这是来自 config.inc.php 文件的代码:

Here is the code from the config.inc.php file:

/* Authentication type and info */
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = '';
$cfg['Servers'][$i]['extension'] = 'mysql';
$cfg['Servers'][$i]['AllowNoPassword'] = true;

XAMPP 的文件夹中(在 Ubuntu 中)还有几个其他的 config.inc.php 文件,但这些文件似乎不包含用户名和密码设置./etc/mysql/my.cnf 文件中有以下几行:

There is a couple of other config.inc.php files in XAMPP's folder (in Ubuntu), but those don't seem to contain username and password settings. There are following lines in the /etc/mysql/my.cnf file:

user        = mysql
socket      = /var/run/mysqld/mysqld.sock
port        = 3306
basedir     = /usr
datadir     = /var/lib/mysql
tmpdir      = /tmp

所以,我可能设置了正确的端口.这个 user = mysql 是什么意思?为什么这些设置会出现无法建立连接"错误?提前致谢.

So, I probably set the right port. What does this user = mysql mean? Why may this "cannot establish a connection" error appear with these settings? Thanks in advance.

推荐答案

user = mysql 是运行 MySQL 守护进程的 OS 用户.从错误消息看来,MySQL 用户 root 的密码不是空的.您应该确定该密码是什么并将其放入身份验证配置中.

user = mysql is the OS user under which the MySQL daemon runs. From the error message, it appears that the MySQL user root has a non-blank password. You should determine what that password is and put it in the authentication config.

这篇关于无法在 NetBeans IDE 中建立与 MySQL 的连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆