Hello all

I am new to Drupal and tried to install it just to see if it can fit my needs for a new website. I followed the instructions for installation, configured my "sites/default/settings.php" file, but when I point to my drupal rot directory I reveive:

"Unable to connect to database server

This either means that the username and password information in your settings.php file is incorrect or we can't contact the MySQL database server. This could mean your hosting provider's database server is down.

The MySQL error was: Unknown MySQL Server Host 'password@localhost' (1).

Currently, the username is aektvco_aektv and the database server is password@localhost.

* Are you sure you have the correct username and password?
* Are you sure that you have typed the correct hostname?
* Are you sure that the database server is running? "

My database settings are correct. What am I missing here?

Thanks in advance for any reply.

Nick

Comments

newtoid’s picture

Hi
you need to specify your username and password correctly.
for example, if the username for your database is aektvco_aektv and the password for your database is malarky and your database is called poohbear, then you need to edit your settings file (line 81 i think) to read:

$db_url = 'mysql://aektvco_aektv:malarky@localhost/poohbear;

also, did you import database.mysql into your database? that will create the drupal database for you

null21’s picture

scruffy

The line's parameters are declared correctly. No doubt about that. I have set all these (user, password, database etc). just fine. There's something else going on....

Heine’s picture

It looks like the URL isn't parsed properly. Does any component of the url contain a 'forbidden' character?

From install.txt
* Note that the $db_url variable gets parsed using PHP's built-in
* URL parser (i.e. using the "parse_url()" function) so make sure
* not to confuse the parser. If your username, password
* or database name contain characters used to delineate
* $db_url parts, you can escape them via URI hex encodings:
*
* : = %3a / = %2f @ = %40
* + = %2b ( = %28 ) = %29
* ? = %3f = = %3d & = %26

--
Tips for posting to the forums

null21’s picture

My password contains an @. Do I have to change it in all my settings? (this will afftect other applications runing on this database right now...)

Anonymous’s picture

... I think Heine's saying that you need to make sure "special" characters are escaped correctly in the settings.php file. So if your username is "aet_aet" and that user's password is "abc@xyz" and the database is "my_drudb", then the db_url needs to be
mysql://aet_aet:abc%40xyz@localhost/my_drudb

That is, you only need to set the settings.php entry to one that will be parsed correctly, not change the actual password (that contains the special character) anywhere.

null21’s picture

DDaniel

I did what you suggested. I recieved a different error response:

The MySQL error was: Access denied for user: 'aektvco_aektv@localhost' (Using password: YES)

it does not recognise the password as correct this time.

newtoid’s picture

try connecting to the mysql server without a password....

null21’s picture

I did this too. The result:

The MySQL error was: Access denied for user: 'aektvco_aektv@localhost' (Using password: NO).

newtoid’s picture

the last thing i can think of is to change 'localhost' to your mysql server name, on one installation i have used a fully qualified server name.

it's quite difficult to diagnose a problem without actually seeing the setup you have.

null21’s picture

OK, I did a clean new isntallation in a different server, folowed the instructions carefully, and went smoothly to the initial registration process where I have (according to the instructions) to create my first account, which will "automatically become the main administrator account with total control".

Whene trying to submit my username and e-mail addres (for the aacount creation) I receive a popup alert with "the URL is not valid and cannot be loaded".

Therefore, I cannot complete the installation process.

Why is this happening?

Thanks

Heine’s picture

A guess: your $base_url in settings.php is such that links generated with it are invalid.

--
Tips for posting to the forums

kavita’s picture

my password not having any special character but still there is error Unable to connect datacase server. Please give me solution.

mattch’s picture

I just visited this thread hoping to find an answer to your very question. I've been having the same problem. I solved it by allowing my mysql user access to connect from "localhost".

Using the MySQL Administrator I right clicked on my user and selected "Add Host From Which User Can Connect", and typed in "localhost".

It's wierd though because I have never had to do this before. I've been using a fresh install of MySql 4.0.25.

ender21014’s picture

mattch your solution fixed my problem also. Thank you for posting it.

mvc’s picture

Note that you may see this if trying to install with a copy of PHP older than 4.3.3. You will either need to upgrade PHP or try an older copy of Drupal.

d.deman’s picture

I have the same problem. I have my site on my computer and I wanted to download it to a subfolder on my website so I could test it online. I am 100% sure the settings are correct and I know my database isn't down because I can get to it using phpmyadmin and yet I get this error. It worked fine on my computer and now it just keeps showing that error:

Unable to connect to database server

This either means that the username and password information in your settings.php file is incorrect or we can't contact the MySQL database server. This could mean your hosting provider's database server is down.

The MySQL error was: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2).

Currently, the username is username and the database server is localhost.

    * Are you sure you have the correct username and password?
    * Are you sure that you have typed the correct hostname?
    * Are you sure that the database server is running?

For more help, see the Installation and upgrading handbook. If you are unsure what these terms mean you should probably contact your hosting provider.

Even when I download a fresh copy of drupal and load the old database it still shows that error. I don't have mysql administrator so how do I try the option above in sql code?
I have php 4 and 5 and mysql 4.1.20 on my server and I don't have special characters in my password. Does anyone have any ideas?

I tried putting drupal 6 on my site....but that didn't work either. It gives the same error:

Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

Does anyone have any suggestions????? Cause I’m all out.

Heine’s picture

Replace localhost In the database connection string with 127.0.0.1. Alternatively, ask your hosting provider how to use MySQL with .sock files on their server.
--
The Manual | Troubleshooting FAQ | Tips for posting | How to report a security issue.

rohitberi’s picture

I had it working with localhost as server name on Fedora Core 5... After I installed Fedora 6 and copied all drupal files over and recreated database it stopped working...

I reinstalled mysql (4/5/5.1) but nothing worked finally changing host name from 'localhost' to '127.0.01' did the magic.

Cheers,

-B

d.deman’s picture

Changed 'localhost' to your mysql server name and it worked. I found the mysql server name with phpmyadmin on the first page under server. The only thing is that the whole test site is funky because I put the site in a subfolder. Is there any way to fix this?

tquigley’s picture

In my case a stray libmysql.dll was lurking in C:\WINDOWS\system32, probably from an older version of an all-in-one php distro. Once I deleted that .dll everything worked fine. http://news.php.net/php.notes/119931

BWoelkers-1’s picture

Hi,

I'm new to moving the database to a differrent server.

Sources I've read:
K. Moving entire site with databases
moving entire site with databases
Backing up your database

I'm changing my hosting provider to a different server. I checked the server statistics and they are both running the current versions of fantastico, drupal, mysql, and php.

The first problem that I ran into was that fantastico had a problem installing drupal into the site root. So after a little frustration I uploaded drupal manually. So it says that drupal is on there now I have to upload the database.

After following the instructions from the pages above I still got database errors (even after changing my settings.php file). I made sure my default username and password where the same and I even named my database the same. I even tried to use the following SQL code to change it to the original database password:
set password = password("yournewpassword");

Each time I would get the following error: Unable to connect to database server

I downloaded the database two different ways, one at the local host root to just create a whole new database, and the other to with just the tables to install into an existing database. Both do not seem to work for me.

There must be something I overlooked or did wrong. Please help!

BWoelkers-1’s picture

The MySQL error was: Access denied for user 'custfeh7_drpl1'@'localhost' (using password: YES).

Currently, the username is custfeh7_drpl1 and the database server is localhost.

* Are you sure you have the correct username and password?
* Are you sure that you have typed the correct hostname?
* Are you sure that the database server is running?

BillyBob31’s picture

Error: Access denied for user 'root'@'localhost' (Using correct password: YES)

* Are you sure you have the correct username and password? Yes
* Are you sure that you have typed the correct hostname? Yes
* Are you sure that the database server is running? Where do i check this.

If anyone can help plz do. thx guys =)

andren’s picture

Almost broke my teeth out in frustration.

Went to phpMyAdmin saw my ip at the top was not localhost. So I changed the server from localhost to that IP in the advanced tab - and it worked.

Hope this saves some teeth out there.

tonino66’s picture

I am using server2go for local drupal installation and had connect problems with the new Drupal 6 installation. The reason was an other mysql port !!! The default mysql port is 3306. Maybe this helps someone.

lejon’s picture

If you want detailed step-by-step set-up of Drupal on Server2Go try this:

http://drupal.org/node/176730#comment-990776

Feedback welcome as there may be a few security issues...

nipper-1’s picture

I have just hdd 2 drupal sites go down within 5 days, using different hosts. Anyway, both of them were working fine, for weeks and week. then all of a sudden, they stopped. I will discuss the second one, the more important of the 2.

It is running off a 1and1 host. It has worked fine, however 1and1 did just make some changes to their hosts last week. i can connect to the database through the 1and1 servers ok, i can conenct to the webspace through dreamweaver, i have checked and double checked all the details, they are all correct. The error is

Failure to connect to your MySQL database server. MySQL reports the following message: Unknown MySQL server host 'db****.oneandone.co.uk' (1).
(note: I have marked my database number with ****)

I am sure people will say 'call 1and1' which i have tried ut they are busy, I get in a queue, then get cut off. So, is anyone else having this problem? With 1and1? Any fix?

thanks

Spook-1’s picture

There are two different ways to connect to a MySQL database. Locally (from a script on the server, to the server), and Remotely (from a remote computer, using Shell, ODBC, or Navicat)

Locally, the settings are:
Hostname = localhost
Username = username_dbuser
Password = dbpassword
db_name = username_dbname
db_table = dbname_table

snagamatch.com

mplumb’s picture

nipper,

Did you find an answer to this as it pertains to 1and1? I have been having the same problem.

I just now got an error message that I can connect to a local mysql server through a socket. Any help appreciated.

I had a drupal 6 site running successfully, but I changed databases and domain names (and all relevant links in the settings files), and now it seems that the problem is with mysql, maybe specific to 1and1 user/admin settings?

livefordo’s picture

Hi Guys,

I am sivakumar. The same error i got . But i solved it

Just login to your PHPMyAdmin account now you can see the SERVER name in the top for
ex: Server: xxxxxxxx (It's server ip)...That is your database host copy and use it .... That's all :-)

Thanks to drupal
Sivakumar.S
www.pokkisam.com