No announcement yet.

Database connection error

  • Filter
  • Time
  • Show
Clear All
new posts

  • Database connection error

    I'm currently trying to move my forum from a Bluehost shared hosting account, to a dedicated 1and1 managed server.

    I've backed up the file structure and uploaded that to the new server, and I've backed up the database, created a new database on the new server, and have successfully accessed the database via SSH and phpmyadmin, so I know all of the data was migrated successfully.

    The database was also backed up from a mysql 5 db and the new server is also using mysql 5, so I don't think there were any version differences. Or could they be issues?

    Finally I edited the includes/config.php file and added the new database details.

    However this is where I'm now stuck. When I try to go to the forum I get a database error screen appearing, and looking at the source code it is reporting the following error:

    Database error in vBulletin :

    mysql_connect() [<a href='function.mysql-connect'>function.mysql-connect</a>]: Can't connect to local MySQL server through socket '/tmp/mysql5.sock:3306' (2)
    /homepages/x/dxxxxxxxxx/htdocs/forum/includes/class_core.php on line 311
    So I then tried a small php script in the same directory on the server and that worked correctly, connecting to the mysql database and reporting back its details.

    The script I used to test it is as follows:


    echo "MySQL test ";
    $link = mysql_connect("$hostname", "$username", "$password", "$database");
    echo $link."<br />";//should get a resource here
    /* check connection */
    if (!$link) {
    printf("Connect failed: %s\n". mysql_error());
    echo "It failed MySQL said ".mysql_error();
    echo "System status: \n". mysql_stat($link);
    As I said, that php script connects to the database perfectly. So why can't vBulletin connect? Are there any other files and settings I need to change from the original installation to make it work on the new 1and1 managed server?

    I did wonder if the port number was wrong for the mysql server, as I've seen it shown as 3316 in a couple of places, so I did try that, but with no success.

    Also can mysqli be used on 1and1 dedicated managed servers? (obviously I just want to get the database connecting first).

    And final thought. Does it matter what the domain is that I'm using on the new server while I'm migrating the site? Obviously I don't want to redirect the real domain to the new location until I know it's working correctly.
    Last edited by Amiga Harrison; Tue 24 Feb '09, 8:29am.
    Retro Amiga gaming. Come visit us as

  • #2
    Does anyone have any ideas what the problem could be? I really need to get this forum moved to the new server this week, and this is the final bit stopping it from working, and I have no idea what else to try.
    Retro Amiga gaming. Come visit us as


    • #3
      I've now just tried to install a fresh copy of vBulletin and I get exactly the same error during the setup process.

      I uploaded the vB files, created a new mysql5 DB, entered the details into the config.php file, then entered the setup. It gets as far as connecting to the database and then stops with the error.

      Attempting to attach to database
      Error description: mysql_connect() [function.mysql-connect]: Can't connect to local MySQL server through socket '/tmp/mysql5.sock:3306' (2) /homepages/x/dxxxxxxxxx/htdocs/test_forum/includes/class_core.php on line 311
      The database has failed to connect because you do not have permission to connect to the server. Please confirm the values entered in the 'includes/config.php' file.
      This is driving me mad because I just don't know why.

      I've setup Joomla on the same server today and it connected to it's database perfectly and worked first time. So why won't vBulletin connect to its database?
      Retro Amiga gaming. Come visit us as


      • #4
        Did you assign a user to the forum database?


        • #5
          On 1and1 managed servers you setup the database via the 1and1 control panel, rather than directly via mysql, and are automatically assigned a user, password, database name etc... They have it configured to work in the same way as their shared hosting accounts, but with the databases hosted locally on the same server, and with unlimited size.

          I think the problem has something to do with how 1and1 are now configuring their mysql setup. Until this month they only provided managed servers with mysql 4 and these used the standard socket and standard mysql port. But last week they upgraded them to allow mysql 5 databases. However to access a mysql database you need to access them using a different socket.

          The details they give are for each database are as follows:

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

          When I setup a Joomla site I just used "localhost:/tmp/mysql5.sock" as the hostname, and it didn't ask for a port number. And that connected and worked perfectly. As did writing the small script shown in my original post above.

          However, whatever I try to put for the hostname and port in the config.php file for vB refuses to work. It just keeps returning the same error messages.

          Doing some searching I have found something relating to this on the German vB site which seems to suggest they have encountered the same problem:

          I gather from that thread that they were replacing the port number with the socket location, but I tried that and it still didn't work. But I can't speak German and don't quite get what the thread is saying to do. Any ideas from that thread on how they fixed it?
          Retro Amiga gaming. Come visit us as


          • #6
            The error message at post #3 suggests you're trying to connect using port 3306, which is a standard line in config.php.

            You mention 1and1 use port 3316 - try editing config.php to use that port instead - line 54 of config.php.

            Failing that, I'm sure you wouldn't be the only person running a vBulletin install on their servers, so you should be able to ask them what the problem is. I've read numerous stories of problems with them running non-standard set-ups.


            • #7
              I've tried using port 3316 but it still doesn't work.

              I then get the error:

              mysql_connect() [&lt;a href='function.mysql-connect'&gt;function.mysql-connect&lt;/a&gt;]: Can't connect to local MySQL server through socket '/tmp/mysql5.sock:3316' (2)
              The problem I have is that 1and1 support is generic and not that helpful. They are such a large hosting company that they just don't have the time to handle personal problems very well. Normally when I try to contact the support I get a quite generic reply about 2 days later! Normally pointing me towards their existing FAQs.
              Retro Amiga gaming. Come visit us as


              • #8
                Just tried a google site search for 1and1 and couldn't find anything good - sorry.


                • #9
                  You need to contact your webhost about this. There is little that we can do since this is very specific to your webhost.


                  • #10
                    I emailed them yesterday about it, but they still haven't got back to me yet, and because the host is 1and1 I'm not really holding my breath that they will be that useful in their reply.

                    One question I need to know from the vBulletin team is what happens when the database server requires a different socket to connect to it? As is the case with this server I'm trying to use?

                    Should it work as I have been trying, by just placing it in the config.php file like this:

                    $config['MasterServer']['servername'] = 'localhost:/tmp/mysql5.sock';
                    $config['MasterServer']['port'] = '3316';
                    Because, from the post on the German vB forum I have linked to above, they seem to be saying that vB isn't coded to handle this. Can you confirm this?
                    Retro Amiga gaming. Come visit us as


                    • #11
                      The socket is the port.


                      • #12
                        That's what I thought. So should putting the socket location into the port entry work? Because when I've tried it doesn't.

                        So what can be the reason for vB not connecting to the database? As I mentioned above, I've setup other data driven sites on the same server this week, using "localhost:/tmp/mysql5.sock" as the host name, and not having to state a port number, and they have all connected to the database perfectly without issue.

                        This seems very strange that just vB cannot connect, but all other data driven software including Joomla and Wordpress can without any problem.

                        And as mentioned before, I also wondered if it was a setting in my backup of the forum's file structure, so tried to install a new copy of vB on the server, but had the same error.
                        Retro Amiga gaming. Come visit us as


                        • #13
                          The connection is failing because you dot not have permission to connect. Double check your values.


                          • #14
                            The values are all correct. I can connect to the database via ssh using exactly the same values, and I created a small test php file to directly connect to the database and that worked too.

                            So it is only vB that for some reason won't connect.

                            I've now opened a support ticket as requested by Marco on and he is going to take a look for me.
                            Retro Amiga gaming. Come visit us as


                            • #15
                              Can you start a support ticket if you havent already?


                              widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.