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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
12-23-2007, 04:16 PM
|
#1
|
LQ Newbie
Registered: Dec 2007
Posts: 4
Rep:
|
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();
}
?>
|
|
|
12-23-2007, 04:25 PM
|
#2
|
Senior Member
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,290
|
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).
|
|
|
12-23-2007, 05:49 PM
|
#3
|
LQ Newbie
Registered: Dec 2007
Posts: 4
Original Poster
Rep:
|
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
|
|
|
12-23-2007, 06:58 PM
|
#4
|
LQ Newbie
Registered: Dec 2007
Posts: 4
Original Poster
Rep:
|
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();
}
?>
|
|
|
12-23-2007, 10:57 PM
|
#5
|
Senior Member
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,290
|
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 07:51 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|