LinuxQuestions.org
Register a domain and help support LQ
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 01-15-2013, 06:18 AM   #1
boloo
LQ Newbie
 
Registered: Jan 2012
Posts: 15

Rep: Reputation: Disabled
PHP Warning: mysql_connect(): Access denied for user 'www'@'localhost'


Hello All,

I am having serious problem with this error. We had old SME server, needed to move to new server., old server also has intranet site for local application, in php and mysql. So I used the affa , outline in http://wiki.contribs.org/Moving_SME_to_new_Hardware . After rising the backup server to production server, when I go to intranet, I am getting mysql_connect() error. I dont have password for mysql, I can log in to mysql without password from command line. the strange thing was , I backup mysql databases and restored to one of the test machine and copied all the folders and files from /home/e-smith/files/ibays , it worked, not sure what is happening here. Please help.
 
Old 01-15-2013, 06:36 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
well fundametnally it's a pretty simple error. there is somethign wrong with the credentials you're using, either the app is using them wrong, or they are not correct / don't exist in the database. So if you're restored the DB, look in the dump for the appropriate GRANT entries and such like.

Code:
mysql> CREATE USER 'monty'@'localhost' IDENTIFIED BY 'some_pass';
mysql> GRANT ALL PRIVILEGES ON <database>.* TO '<user>'@'localhost'
    ->     WITH GRANT OPTION;
 
Old 01-15-2013, 07:22 AM   #3
boloo
LQ Newbie
 
Registered: Jan 2012
Posts: 15

Original Poster
Rep: Reputation: Disabled
Thanks man,
I am trying to create the user
CREATE USER 'monty'@'localhost' IDENTIFIED BY 'some_pass'; exactly as it is , and getting ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'USER 'monty'@'localhost' IDENTIFIED BY 'some_pass'' at line 1 . What I am getting when I go to local site is, "Warning: your browser was not able to connect to the database-server. Please try to reload the page by clicking on reload. " . The thing I dont understand is exactly the same dbs and php code , supposed to be identical copy using affa as well. I am pulling my hair out..
 
Old 01-15-2013, 07:28 AM   #4
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
well you've not said that you've actually LOOKED at the db setup to see if the user should be able to log in or not.
 
Old 01-15-2013, 07:43 AM   #5
boloo
LQ Newbie
 
Registered: Jan 2012
Posts: 15

Original Poster
Rep: Reputation: Disabled
Hi Chris,

I just set the root user with password, and set it in the php files variable. no more of connection error in log, but not displaying anything either. So checking the log at the moment,
 
Old 01-15-2013, 07:50 AM   #6
boloo
LQ Newbie
 
Registered: Jan 2012
Posts: 15

Original Poster
Rep: Reputation: Disabled
It seemed to be wokring now, I am suprised that same code same databases and same users not working. Thank you very much your help man, that saved my life
 
Old 01-15-2013, 08:01 AM   #7
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
root??? I hope this is not a public facing site, or you're going to regret that.
 
Old 01-15-2013, 08:06 AM   #8
boloo
LQ Newbie
 
Registered: Jan 2012
Posts: 15

Original Poster
Rep: Reputation: Disabled
yep, I know , it is only for internal, but still not the bright idea, but for right now , i just need to prove the concept.
 
Old 01-15-2013, 06:45 PM   #9
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,260

Rep: Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328
This script shows the current grants/users on a db; you'll need the mysql root user's passwd
Code:
mysql -u root -p${1} --batch --skip-column-names -e "SELECT user, host FROM user" mysql | sed 's,\t,"@",g;s,^,show grants for ",g;s,$,";,g;' | mysql -u root -p${1} --batch --skip-column-names | sed 's,$,;,g'
HTH
 
Old 01-16-2013, 03:41 AM   #10
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
MySql changed the password hashing somewhere along the line (version 4.1 or so). So old authentications no longer work on newer versions; I think it is possible to configure MySql to use the old hashing but 'm not 100% sure.

That's a possible cause. You can check the passwords in the MySql user database for their length; and the new 'format' password starts with '*' while the old ones don't.
 
  


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
Mysql --- Access denied for user 'test'@'localhost' permalac Linux - Server 15 03-05-2013 09:51 PM
[SOLVED] Why the php mysql_connect() only can connect localhost MySQL? avinc Linux - Server 5 04-18-2011 08:25 PM
Access denied for user 'root'@'localhost' najmul002 Linux - Server 3 12-14-2010 07:23 PM
Folder Permissions :: Access denied for user 'www-data'@'localhost' own3mall Linux - Software 5 08-09-2009 07:52 PM
Access denied for user: 'mythtv@localhost' Red Knuckles Ubuntu 1 10-04-2007 04:12 PM


All times are GMT -5. The time now is 06:09 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration