當我創建Hibernate的一個新的Web項目,我打開新建連接嚮導到MySQL的連接,則選擇MySQL(Connector/J驅動)選項(連接器罐子出現在驅動程序文件列表),我按下一步按鈕,設置主機:127.0.0.1,端口:3306,數據庫名,用戶名:root,空白密碼字段。然後我得到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))
不能建立在NetBeans IDE
下面是來自config.inc.php文件中的代碼:
/* 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文件中有以下行:
user = mysql
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
因此,我可能設置了正確的端口。這個user = mysql
是什麼意思?這些設置爲什麼會出現「無法建立連接」錯誤?提前致謝。
感謝。我剛剛找到答案,會在一分鐘內寫出來。密碼實際上是空白的。 – 2012-03-07 01:41:01