PDA

View Full Version : vB wont connect to database on managed 1and1 server.


Amiga Harrison
02-26-2009, 11:33 AM
I've been trying to move my forum from a shared hosting account with Bluehost, to a dedicated managed server with 1and1.

I've so far backed up the forum's file structure and moved that over to the new server. Backed up the database via ssh, created a new database on the new server, and imported the backup successfully.

However after editing the config.php file and entering the new database's details, and then trying to connect to the forum on the new server I get the following error:

mysql_connect() [<a href='function.mysql-connect'>function.mysql-connect</a>]: Can't connect to local MySQL server through socket '/tmp/mysql5.sock:3316' (2)Some information about 1and1 setup:

1and1 upgraded their managed dedicated servers a couple of weeks ago to support mysql 5. Before this they only allowed mysql 4. However to use mysql 5 on a 1and 1 server you need to use a different socket and port number compared to the default settings normally used by mysql.

For my vB database the connection settings are as follows:

Database name dbxxxxxxxxx
Host name localhost:/tmp/mysql5.sock
Port 3316
User name dboxxxxxxxxx
Password xxxxxxxx
Socket /tmp/mysql5.sock

I therefore have been trying to connect to the database using the following settings in the config.php file:

$config['MasterServer']['servername'] = 'localhost:/tmp/mysql5.sock';
$config['MasterServer']['port'] = '3316'; But am getting the error I posted above.

On doing some searching I found a thread on the German vB.org forum that is discussing about this and using mysql 5 with vB on a 1and1 server. However I don't know any German and the web translaters didn't do a very good job of converting the posts. The German thread can be found at:

http://www.vbulletin-germany.org/showthread.php?t=272&page=9

In a couple of the posts it mentions replacing the port entry in config.php with the socket location. I tried that but it didn't work. And in a couple of others it mentioned editing the class_core.php file and adding the socket information into that. But I'm not sure at this point as I did try the example given in the thread but it didn't do anything either.

Can anyone help me solve this problem? I've tried to contact 1and1's support, but they still haven't got back to me and the forum has now been down for nearly 2 weeks already. I was really hoping to get it back online this week.

Oh, and finally. To test it wasn't an issue with my backup of the forum, I used the backup to set the forum up on another server and it restored and worked perfectly, connecting to the new database and working as it should. So it is definitely a problem unique to how 1and1 have set up the way their dedicated managed servers use mysql 5.

I've now exhausted what I can think to do and need some help.

I have posted about this on the main vB.com forums, but they haven't been able to help me yet. That post can be found at http://www.vbulletin.com/forum/showthread.php?p=1701307

Marco van Herwaarden
02-26-2009, 12:12 PM
Try:


$config['MasterServer']['servername'] = 'localhost';
$config['MasterServer']['port'] = '/tmp/mysql5.sock';

Amiga Harrison
02-26-2009, 12:17 PM
When trying that I get the following error:


mysql_connect() [<a href='function.mysql-connect'>function.mysql-connect</a>]: Access denied for user 'dboxxxxxxxx'@'localhost' (using password: YES)
/homepages/x/dxxxxxxxx/htdocs/forum/includes/class_core.php on line 311


Worth noting though, is that I also get this error in ssh if I try to log into mysql without putting "-S /tmp/mysql5.sock" in the mysql shell command. Does this therefore indicate that vB cannot find the socket like this? And is therefore ignoring the entry in the port setting? I also noticed when looking through the class_core.php file that port 3306 is hard coded into 4 different places in the code.

Marco van Herwaarden
02-26-2009, 01:00 PM
Can you please verify with your host that the MySQL user & password are correct. The error message you get now indicates the wrong user or password, or the user does not have permision to the database.

Marco van Herwaarden
02-26-2009, 01:04 PM
You can also give the following a try:

$config['MasterServer']['servername'] = '127.0.0.1';
$config['MasterServer']['port'] = '3316';

Edit: Are you using MySQL or MySQLi?

Amiga Harrison
02-26-2009, 01:55 PM
Can you please verify with your host that the MySQL user & password are correct. The error message you get now indicates the wrong user or password, or the user does not have permision to the database.

Yes, the user and password are correct.

I get the same error when trying to connect to a database via ssh if I don't include the socket. But if I do include the socket then it connects properly.

You can also give the following a try:

$config['MasterServer']['servername'] = '127.0.0.1';
$config['MasterServer']['port'] = '3316';

Edit: Are you using MySQL or MySQLi?

I'm using MySQL.

On trying those details I get the following error:

mysql_connect() [<a href='function.mysql-connect'>function.mysql-connect</a>]: Lost connection to MySQL server at 'reading initial communication packet', system error: 111
/homepages/x/dxxxxxxxxx/htdocs/forum/includes/class_core.php on line 311

Marco van Herwaarden
02-26-2009, 02:04 PM
Please open a support ticket regarding this. Make sure to include all needed info including access to AdminCP, FTP (and if possible SSH) & phpMyAdmin. Please use "FAO: Marco" as title for the ticket and i will have a look. But i will probably not respond until tomorrow (if you don't want to wait until tomorrow, you can use any other title and a co-worker will have a look, but will probably start with default solutions).

Amiga Harrison
02-26-2009, 02:18 PM
OK thanks. I will open a ticket now.

BSMedia
02-26-2009, 05:14 PM
I've never seen a host name formed like that, I'd contact 1&1 especially since its managed and ask about the settings they gave you.

Amiga Harrison
02-26-2009, 10:58 PM
I've finally managed to fix the database connection issue. 1&1's support finally got back to me with some suggestions and for once they worked.

For anyone else who might be using a 1&1 managed dedicated server, this is what you need to do.

1, From the 1and1 Control Panel - Go to the server Administration section and make sure PHP is running as a module.

2, Create a .htaccess file and put the following line into it.

php_value mysql.default_socket "/tmp/mysql5.sock"

And put this .htaccess file into the root of the forum directory.

3, Enter the following settings into the vB config.php file.

$config['MasterServer']['servername'] = 'localhost';
$config['MasterServer']['port'] = '/tmp/mysql5.sock';

And this fixed my problem.

However I do now have another problem. When I try to log into the forum I get a server 500 error, and when I try to log into the admincp it just throws me back out to the admin login screen. Any ideas what could be causing that problem?

BSMedia
02-27-2009, 03:04 AM
I've finally managed to fix the database connection issue. 1&1's support finally got back to me with some suggestions and for once they worked.

For anyone else who might be using a 1&1 managed dedicated server, this is what you need to do.

1, From the 1and1 Control Panel - Go to the server Administration section and make sure PHP is running as a module.

2, Create a .htaccess file and put the following line into it.

php_value mysql.default_socket "/tmp/mysql5.sock"

And put this .htaccess file into the root of the forum directory.

3, Enter the following settings into the vB config.php file.

$config['MasterServer']['servername'] = 'localhost';
$config['MasterServer']['port'] = '/tmp/mysql5.sock';

And this fixed my problem.

However I do now have another problem. When I try to log into the forum I get a server 500 error, and when I try to log into the admincp it just throws me back out to the admin login screen. Any ideas what could be causing that problem?


A malformed .htaccess most likely. Do you have a fill called error_logs on the server that could probably pinpoint the cause.

Marco van Herwaarden
02-27-2009, 06:44 AM
Good to hear your conection problem has been solved and thanks for posting the information here so it is also usefull for other customers of 1and1.

Dismounted
02-27-2009, 07:51 AM
when I try to log into the admincp it just throws me back out to the admin login screen.
If you have set your own cookie path/domains, reset them using tools.php.

Amiga Harrison
02-27-2009, 10:36 AM
Yep. I realised that straight after posting and used tools.php to reset the cookie path/domains. All is now working correctly. :)

Thanks everyone for trying to help.

--------------- Added 1235738920 at 1235738920 ---------------

A malformed .htaccess most likely. Do you have a fill called error_logs on the server that could probably pinpoint the cause.

No. 1&1 have their servers configured in a unique way. To access mysql 4 databases you just use the normal localhost and it connects with the standard "/tmp/mysql.sock" socket. However to access mysql 5 databases you have to connect using a second "/tmp/mysql5.sock" socket.

1&1 only upgraded their managed servers to support mysql 5 databases a couple of weeks ago, so this is kind of a bolted on addition. They are still supporting existing created mysql 4 databases on the servers, but only allowing mysql 5 for any new databases created. So I think they are slowly trying to phase out version 4, while still maintaining support for both using different sockets.

And as this is so new on their managed servers I expect most vB users haven't encountered this issue yet as they will still be using mysql 4 databases with their forums. However as new installations are setup on 1&1 servers I'm sure more people will encounter this problem, and I hope the solution I found will be useful for others using 1&1. :)

I do however wish 1&1 had notified it's customers directly about this update and given some details about how it worked. Instead they just rolled out the mysql 5 support quietly, and the first I knew about it was when I logged into the 1&1 control panel for my server and there was a notice on the database admin page. But even that didn't mention the socket use. I had to dig through the 1&1 FAQs to find that info. Although I have to say, they had updated their FAQs quickly to support the changes (although obviously not mentioning the .htaccess solution I've used).

metrika
04-23-2010, 06:34 PM
It works on my vb 3.x ,Thanks! ;), but I have more licences and I can not run a vb 4.0 on the same host (1and1 Dedicate server).
When I try to migrate my vb 4.0 to the same host space I get this error:
Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /homepages/30/d325399689/htdocs/todobetas.com/forum.php on line 598

Any solution?

--------------- Added 1272124605 at 1272124605 ---------------

I found the solution to install VB 4.x on 1and1 dedicated server:

1) I run PhP as a module.

2) I change the follow lines on config.php to be like this:
$config['MasterServer']['servername'] = 'localhost';
$config['MasterServer']['port'] = '/tmp/mysql5.sock';

3) I add the follow lines on the .htaccess on the vb4.x directory:

php_value mysql.default_socket "/tmp/mysql5.sock"
AddType x-mapp-php5 .php



Looks like all are working ok now.