1
我已經通過的cPanel創建一個數據庫和數據庫用戶,如下創建test_database 數據庫用戶:test_user通過PHP連接到MySQL數據庫使用的cPanel
我試圖連接到這個數據庫
<?php
$servername = "localhost";
$username = "test_user_test_database";
$password = "test";
// Create connection
$conn = mysqli_connect($servername, $username, $password);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
?>
但是我結束了:
Warning: mysqli_connect(): (28000/1045): Access denied for user 'test_user_test_database'@'localhost' (using password: YES) in /home/driver/public_html/login/connect.php on line 7
Connection failed: Access denied for user 'test_user_test_database'@'localhost' (using password: YES)
通過下面的PHP腳本在同一臺服務器上
問題在於用戶名和數據庫名稱中有下劃線嗎?或者有沒有辦法解決這個問題?我寧願保留用戶名和數據庫名稱,因爲它們是如此想要檢查是否有其他方式圍繞它
根據你的寫法,你的數據庫用戶名是'test_user',但是在你的連接中你可以使用'test_user_test_database' – lolbas
根據這個http://forums.cpanel.net/f354/connecting-php-page-mysql-database -56011.html它需要採取的形式username_databasename –
它會更好地使用此資源作爲參考:http://php.net/manual/en/function.mysqli-connect.php不:http://論壇.cpanel.net/F354 /連接 - PHP頁面MySQL的數據庫,56011.html –