473,378 Members | 1,280 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Could not connect: Access denied for user

I am getting the below error when attempting to run a php script on my server which accesses a mysql table I have created in an existing database. I can connect to the database table via the MySQL workbench, but not via a php script I have written. This database was originally created for use with Magento Cart, which I have installed and which works correctly (can access it's database tables). I simply cannot access the database with a separate script which I have separately created. The script runs and echoes the statement to the screen, but then fails on the connection.

Could not connect: Access denied for user 'cars2'@'VWEB2' (using password: YES)PHP Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'cars2'@'VWEB2' (using password: YES) in C:\HostingSpaces\car.accessories\caraccessories.co m\wwwroot\magento\uploadQuestion.php on line 4


------------------php script--------------

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. echo "test<br>";
  4. $con = mysql_connect("server", "username", "password");
  5.  
  6. if (!$con)
  7.   {
  8.   die('Could not connect: ' . mysql_error());
  9.   }
  10.  
  11. mysql_select_db("cars2", $con);
  12.  
  13. $sql="INSERT INTO survey_questions (survey_question_text, survey_question_visible, survey_question_options, survey_question_style) VALUES ('$_POST[survey_question_text]',,'$_POST[survey_question_status]','$_POST[survey_question_options]', '$_POST[survey_question_style]] )";
  14.  
  15. if (!mysql_query($sql,$con))
  16.   {
  17.   die('Error: ' . mysql_error());
  18.   }
  19. echo "1 record added";
  20.  
  21. mysql_close($con);
  22.  
  23. ?>
Mar 9 '11 #1
5 8870
mwasif
802 Expert 512MB
User cars2 does not have privileges to connect to the database from server VWEB2.
Mar 9 '11 #2
The user cars2 is the user account that my Magento installation uses to connect to the very same database from the very same server. Ergo, it has the appropriate permissions at the database level. This is a new table in the existing database.
Mar 9 '11 #3
mwasif
802 Expert 512MB
Run this query in MySQL and post the results here
Expand|Select|Wrap|Line Numbers
  1. SHOW GRANTS FOR 'cars2'@'VWEB2';
Did you specify the same server name for Magento in mysql_connect()?
Mar 9 '11 #4
The server name was specified as the server name (which is sql2.domainname.com). The return of the statements is below (first is with the vweb2 host, second is without. I'm not sure where the vweb2 is coming from, unless it is an internal network DNS name that is being applied by the server.

SHOW GRANTS FOR 'cars2'@'VWEB2'
Error Code: 1141
There is no such grant defined for user 'cars2' on host 'VWEB2'

If I use the actual server name, I get the same thing
SHOW GRANTS FOR 'cars2'@'sql2.host.com'
Error Code: 1141
There is no such grant defined for user 'cars2' on host 'sql2.host.com'

SHOW GRANTS FOR 'cars2';
(which appends @%)
2 row(s) returned
'GRANT USAGE ON *.* TO ''cars2''@''%'' IDENTIFIED BY PASSWORD ''*B2BE71AE30F60BB25F7C6B25C77591F34E20BE99'''

'GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE ON `cars2`.* TO ''cars2''@''%'' WITH GRANT OPTION'
Mar 9 '11 #5
Late update on this resolution... I'd stored the password in MySQL Workbench, and so hadn't been typing it in for a while. My host changed the password a while back. I updated it in Workbench, but never got rid of the original e-mail... short version, I was using the wrong password to try to connect.
May 29 '11 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: photoelectric | last post by:
When trying to run the below script on an apache/1.3.26 with mysql and php I get the following error message: Warning: mysql_connect() : Access denied for user: 'nobody@software-ece.rutgers.edu'...
3
by: red | last post by:
I know this is probably a faq but it is hard to search for this exact problem. When I put this on a php page: <? $link = mysql_connect("localhost", "cardini", "password") or die("Could not...
0
by: Ryan Schefke | last post by:
------=_NextPart_000_0077_01C34C8B.2B90C960 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit ..I just sent this out to the win32 distribution list but no one has...
2
by: adnan alsamari | last post by:
Hi, I can only access mysql through the root by typing mysql -u root -p. But when I use any other user to connect to mysql I get the access denied error message. Mysql is installed on windows xp. ...
0
by: Manfred Braun | last post by:
Hi All, I've already asked another question , but this is finally the same issue. I cannot execute two asynchron WMI queries on the local machine, one after the other. The original question is...
9
by: | last post by:
Hi All, I have allready tried to ask a similar question , but got no answer until now. In the meantime, I found, that I cannot understand some thread-settings for the Main() function . If I use...
4
by: geodev | last post by:
I have developed a small application using ASP.NET and VB.NET on my development machine it works great. When I copy across the files manually to my test machine and create a Virtual Directory all...
2
by: Johan Johansson (Sweden) | last post by:
I can't connect to our database (seperate database server) from within my webservice. I cannot understand why.!!! * I have configured IIS not to allow anonymous access and to use "windows...
1
by: servo | last post by:
I created a user "test1" (which then got the username "debscrof_test1" from CPanel), a password for the user "test2", and then added the user to a new database "testdb" with all priviliges Then a...
2
by: sbettadpur | last post by:
hello I am getting following error while connecting to mysql through php Warning: mysql_connect() : Access denied for user: 'pds@localhost' (Using password: YES) Actually I hosted one...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.