FEDORA /MYSQL Issue
Hi All,
I have a virtual dedicated server hosted by godaddy and I seem to be having 'permission' issues connecting to mysql from a site hosted on the local server. I have a script (db.php) on the local site that is suppose to connect the database but each time i run the script, the following error is displayed on the browser: Could not connect to the database. Error = Access denied for user 'xMulch89'@'localhost' (using password: YES) It does not matter wheather i use root or any other user, I still get the error message.I am able to log onto mysql as root or any user from bash /view tables/modify I have also tried modifying the hosts.allow file but obviously that did not help. What am i doing wrong? Please help: Below is a copy of db.php file <?php $db_host = "localhost"; $db_user = "xMulch89"; $db_password = "xxxxxxx"; $db_name = "Webstore1"; $connect = mysql_connect("$db_host", "$db_user", '$db_password'); if ($connect){ echo "Congratulations!\n<br>"; echo "Successfully connected to MySQL database server.\n<br>"; }else{ $error = mysql_error(); echo "Could not connect to the database. Error = $error.\n<br>"; exit(); } ?> |
Can you login from mysql on the command line and execute the following:
Code:
use mysql Code:
select user,host,password from user |
FEDORA /MYSQL Issue
Ok I have done the following as advised but I am still not getting anywhere
1. checked the user table in mysql and verified that the user xMulch89 is there and associated to localhost for database Webstore1 (All Privileges) Deleted and recreated user 2. Nothing on mysql log 071223 14:03:43 mysqld started 071223 14:03:43 InnoDB: Started; log sequence number 0 43665 071223 14:03:43 [Note] /usr/libexec/mysqld: ready for connections. Version: '5.0.45-log' socket: '/var/lib/mysql/mysql.sock' port: 3306 Source distribution 071223 14:36:24 [Note] /usr/libexec/mysqld: Normal shutdown 071223 14:36:24 InnoDB: Starting shutdown... 071223 14:36:27 InnoDB: Shutdown completed; log sequence number 0 43665 071223 14:36:27 [Note] /usr/libexec/mysqld: Shutdown complete 071223 14:36:27 mysqld ended 071223 14:36:47 mysqld started 071223 14:36:47 InnoDB: Started; log sequence number 0 43665 071223 14:36:47 [Note] /usr/libexec/mysqld: ready for connections. Version: '5.0.45-log' socket: '/var/lib/mysql/mysql.sock' port: 3306 Source distribution 3. Php.ini error reporting set to: error_reporting = E_ALL & ~E_NOTICE | E_STRICT Previously: error_reporting = E_ALL |
FEDORA /MYSQL Issue
Fixed!!
I finally figured it out - all in the syntax (missing the double quotes "" ). <?php $db_host = "localhost"; $db_user = "xMulch89"; $db_password = "xxxxxxx"; $db_name = "Webstore1"; $connect = mysql_connect("$db_host", "$db_user", '$db_password'); if ($connect){ echo "Congratulations!\n<br>"; echo "Successfully connected to MySQL database server.\n<br>"; }else{ $error = mysql_error(); echo "Could not connect to the database. Error = $error.\n<br>"; exit(); } ?> |
Aha ... that's right ... IIRC PHP will take a single quoted string literally, instead of substituting for the variable. Python's been my Web programming language of choice lately and I haven't done anything with PHP for a couple years, so I didn't catch that. I think it would also work with no quotes at all in this case.
|
All times are GMT -5. The time now is 11:52 PM. |