MySQL Connection Errors

From Free Hosting Wiki
(Difference between revisions)
Jump to: navigation, search
m (Username)
(remove from KB)
 
(5 intermediate revisions by 3 users not shown)
Line 1: Line 1:
This article describes what to do if your code attempts but fails to connect to the X10 MySQL server.  Usually, this means you get an error such as "''SQLSTATE[28000] [1045] Access denied for user 'user_name'@'int.host.x10hosting.com' (using password: YES)''". Basically, the solution amounts to checking the [[MySQL information]].
+
When your script (or CMS) attempts - but fails to connect to X10hosting's MySQL server - you usually receive an error message - such as:<br>
 +
"''SQLSTATE[28000] [1045] Access denied for user 'user_name'@'localhost' (using password: NO)...''"
 +
<br>
 +
 
 +
 
 +
 
 +
For MySQL connection to work it needs three (3) pieces of information which must match what is on the MySQL server:
 +
<br>
 +
 
 +
* Host
 +
* Username
 +
* Password
 +
 
 +
 
 +
 
 +
== Host ==
 +
The host name must be [ localhost ]
 +
<br>
 +
If you see in the error message [ ...'@'localhost' ] that is good
 +
<br>
 +
but if you see  [ ...'@'baddog.com' ] or anything else - that is not good
 +
<br>
 +
 
  
[http://dev.mysql.com/doc/refman/5.0/en/user-names.html MySQL authentication] is based on three pieces of information which need to match what's on the server, so an "access denied" error has four potential causes:
 
* Wrong username.
 
* Wrong password.
 
* The client computer isn't allowed.
 
* Wrong server.
 
  
 
== Username ==
 
== Username ==
When you [[How to Create a MySQL Database and User|create a user]] using cPanel, your cPanel name and an underscore are prepended to it to create the database username. For example, if your cPanel name is "foo" and you create the user "bar", the actual database username is "foo_bar". If you leave out the prefix, the connection will fail.
+
When you create a user with cPanel - your cPanel username and an underscore are added to the front of it - you do not add it - cPanel does
 +
<br>
 +
Example - if your cPanel username is [ bigboys ] and you create the user [ toy ] - the database username is [ bigboys_toy ] - not [ toy ]
 +
<br>
 +
 
  
 
== Password ==
 
== Password ==
Double check that your code uses the correct password for the user. If it doesn't give a password when connecting, the connection will fail. If you see "''(using password: NO)''" in the error message, this is the cause.
+
If you see in the error message [ ...(using password: YES)... ] that is good<br>
 +
but If you see in the error message [ ...(using password: NO)... ] that is not good<br>
  
You can change the password for an existing user by following the steps to [[How to Create a MySQL Database and User#Creating_only_a_user|create a user]] but give the name (sans prefix) of an existing user. Try temporarily changing the password to something that only uses digits (except 0 and 1) and lower case letters (except l). Make sure you change it to something more complex afterwards.
+
your script (or CMS) must give the correct password when connecting<br>
 +
[ Cat+2Dogs! ] is not the same as [ cat+2dogs! ]
 +
<br>
  
== Host ==
 
As per the [[MySQL information]], the host should be "localhost". Note that you don't need to specify the port.
 
  
== Client computer ==
 
[http://dev.mysql.com/doc/refman/5.0/en/user-names.html MySQL accounts] are identified by the database username and the hostname of the client computer combined. If there's no entry for both together, the connection will fail. Normally, your X10 host should have been given access to the MySQL server when your account was created or moved, but sometimes this needs to be configured manually, which you can do from within cPanel:
 
  
# Note the server name in the error message. In the example error at of the top of this article it's "int.host.x10hosting.com".
+
Check your settings with [[MySQL Information|MySQL information]].
# Sign into cPanel.
+
<br>
# Note your server name in the "Stats" panel on the left.
+
# In the "Databases" panel, click "Remote MySQL"
+
# Make sure you see something like the following entries. Italics indicate a value that you may need to customize. If any are missing, add them.
+
#* 10.33.248.% (internal IP block for int.vital.x10hosting.com)
+
#* 10.33.''249''.% (internal IP block for int.''host''.x10hosting.com)
+
#* 10.33.''249''.''2'' (internal IP for int.''host''.x10hosting.com; you'll likely need something different)
+
#* 192.168.1.%
+
#* int.''host''.x10hosting.com
+
#* int.mysql.x10hosting.com
+
  
The first two entries you see may vary from the above, and the third will likely be different. You can get the correct value for the first by running a [http://www.google.com/search?q=DNS+query DNS query] for "int.vital.x10hosting.com" to get its [http://en.wikipedia.org/wiki/IP_address IP address], then substituting "%" for the last [http://en.wikipedia.org/wiki/Dot-decimal_notation quad]. Get the correct value for the second by doing the same for the host name from the error message, or by substituting your server name from step 2 for ''host''. The correct value for the third is the same as for the second, but without substituting '%'.
 
  
Not all of the entries may be necessary, but neither should they cause problems. From my account, I also see a "69.162.70.130", but I suspect this is an old IP for one of the hosts I've been on.
+
'''Note: Free hosting accounts do not have remote MySQL access - you can only access MySQL data via a script (or CMS) and phpMyAdmin'''
 +
<br>

Latest revision as of 01:13, 17 January 2012

When your script (or CMS) attempts - but fails to connect to X10hosting's MySQL server - you usually receive an error message - such as:
"SQLSTATE[28000] [1045] Access denied for user 'user_name'@'localhost' (using password: NO)..."


For MySQL connection to work it needs three (3) pieces of information which must match what is on the MySQL server:

  • Host
  • Username
  • Password


[edit] Host

The host name must be [ localhost ]
If you see in the error message [ ...'@'localhost' ] that is good
but if you see [ ...'@'baddog.com' ] or anything else - that is not good


[edit] Username

When you create a user with cPanel - your cPanel username and an underscore are added to the front of it - you do not add it - cPanel does
Example - if your cPanel username is [ bigboys ] and you create the user [ toy ] - the database username is [ bigboys_toy ] - not [ toy ]


[edit] Password

If you see in the error message [ ...(using password: YES)... ] that is good
but If you see in the error message [ ...(using password: NO)... ] that is not good

your script (or CMS) must give the correct password when connecting
[ Cat+2Dogs! ] is not the same as [ cat+2dogs! ]


Check your settings with MySQL information.


Note: Free hosting accounts do not have remote MySQL access - you can only access MySQL data via a script (or CMS) and phpMyAdmin

Personal tools
Namespaces

Variants
Actions