LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-29-2006, 09:46 PM   #1
PAD_LOCK
LQ Newbie
 
Registered: Aug 2006
Posts: 2

Rep: Reputation: 0
cannot connect to mysql database


Hello guys, Im new to ubuntu 6.06 and im having difficulty connecting to mysql database.

Access denied for user ''@'localhost' to database 'database_name'

Im using PHP Script

THANKS GUYs!
 
Old 08-30-2006, 01:48 AM   #2
infestator
LQ Newbie
 
Registered: Jul 2006
Distribution: Gentoo
Posts: 18

Rep: Reputation: 0
Code:
''@'localhost' to database 'database_name'
^                          ^
here should be username    here should be your database's name
you missing username and (it seems so) database_name.
in php you can use mysql_connect first, then mysql_select_db to select database:
Code:
<?php
$mysql_link = mysql_connect ('localhost', 'infestator', 'sample_password');
mysql_select_db ('infestator_db');
?>
 
Old 08-30-2006, 04:25 AM   #3
smallville
Member
 
Registered: Dec 2005
Posts: 44

Rep: Reputation: 15
if you are using a different workstation in connecting to mysql try replacing 'localhost' with the mysql server's ip address.

Also check the user's rights and password.
 
Old 08-31-2006, 02:43 AM   #4
PAD_LOCK
LQ Newbie
 
Registered: Aug 2006
Posts: 2

Original Poster
Rep: Reputation: 0
PHP is installed in another computer which is our main server while my database MySQL is installed in my computer. Im using my IP address as my localhost.
 
Old 09-01-2006, 02:37 AM   #5
smallville
Member
 
Registered: Dec 2005
Posts: 44

Rep: Reputation: 15
then try connecting using ip_add

like

mysql_connect('192.168.1.69', 'username', 'password') or die(mysql_error());
 
Old 09-01-2006, 02:03 PM   #6
xhi
Senior Member
 
Registered: Mar 2005
Location: USA::Pennsylvania
Distribution: Slackware
Posts: 1,065

Rep: Reputation: 45
> Im using my IP address as my localhost.

localhost is 127.0.0.1 not the ip address you are looking for. use smallville's example or something like it (add your ip to the hosts on the server and use the name you specify there, or declare a var to hold your ip, etc,etc,etc.)
 
  


Reply



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
How To Connect To Posgresql/mysql Database Using C cs-mania Programming 4 07-05-2006 11:00 PM
Unable to connect to (working) mySQL database rcs1000 Linux - Software 1 10-16-2005 07:23 AM
cannot connect to mysql database from php rocordial Linux - Software 2 08-21-2005 02:05 PM
cannot connect to mysql database externally lsimon4180 Linux - Software 17 03-02-2005 12:28 PM
cannot connect to mysql database mrosati Linux - Software 19 07-15-2004 02:40 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:08 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