LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-23-2007, 04:16 PM   #1
chaotix2003
LQ Newbie
 
Registered: Dec 2007
Posts: 4

Rep: Reputation: 0
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();
}

?>
 
Old 12-23-2007, 04:25 PM   #2
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,290

Rep: Reputation: 378Reputation: 378Reputation: 378Reputation: 378
Can you login from mysql on the command line and execute the following:

Code:
use mysql
select user,host from user
This will print out the users and the hosts they're allowed to connect from. Do you see xMulch89 and localhost as a valid pair? If so try running:

Code:
select user,host,password from user
and make sure that the password hash for that user is set correctly. If it is, I would suggest looking at the MySQL log in /var/log to see if there are any error messages. You might also want to turn on verbose error logging in PHP as well (see this page for details).
 
Old 12-23-2007, 05:49 PM   #3
chaotix2003
LQ Newbie
 
Registered: Dec 2007
Posts: 4

Original Poster
Rep: Reputation: 0
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
 
Old 12-23-2007, 06:58 PM   #4
chaotix2003
LQ Newbie
 
Registered: Dec 2007
Posts: 4

Original Poster
Rep: Reputation: 0
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();
}

?>
 
Old 12-23-2007, 10:57 PM   #5
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,290

Rep: Reputation: 378Reputation: 378Reputation: 378Reputation: 378
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Buzilla issue: "Can't connect to local MySQL server through socket '/tmp/mysql.sock'" vitopn Linux - General 3 05-21-2007 10:13 AM
Problems Installing/uninstalling MySQL On Fedora Fc4 (library dependency issue) donraja Linux - Software 2 05-26-2006 01:06 AM
Fedora 4 Issue with PHP not recognizing Upgrade to MYSQL DoubleAce3 Linux - General 0 02-17-2006 04:31 PM
fedora core 2, with mysql 5.0 and mysql 3.23 dependencies. ilazarte Linux - Software 1 02-07-2006 04:00 PM
Fedora Core 3, MySql Server, mysql started mysql ended OkiTek Fedora 30 01-28-2005 09:15 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:51 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration