1and1 Help Centre Categories

print article

Connect to a MySQL 5 Database on a 1&1 Managed Server

For 1&1 Managed Server packages

To be able to connect to a MySQL 5 database on a 1&1 Managed Server, you will need the following information from the MySQL Administration section from the 1&1 Control Panel:

  • Database Name
  • Host Name
  • User Name
  • Password

Below you will find general examples of how to connect to your databases using various programming and scripting languages. You will need to replace the database name with your database name and your password etc.

Please note:
You must remember to specify the socket /tmp/mysql5.sock which remains the same for all dedicated website servers.
mysql -h localhost -u dbo111111111 -p -S /tmp/mysql5.sock db111111111



$link = mysql_connect("$hostname", "$username", "$password");
if (!$link) {
die('Connection failed: ' . mysql_error());
echo 'Connection successful';


Please note:
Alternatively you can try $hostname = "localhost;unix_socket=/tmp/mysql5.sock"; if you are having trouble connecting using the hostname value supplied above.


use DBI;

print "Content-type:text/html\n\n";

$hostname= "localhost";
$username= "dbo111111111";
$password= "MyPassword";
$mysqlsocket= "/tmp/mysql5.sock";

$db_handle = DBI->connect("dbi:mysql:database=mysql;host=$hostname;mysql_socket=$mysqlsocket;user=$username;password=$password")
or die "Connection failed: $DBI::errstr\n";

print "Connection successful";

For additional information, you may want to reference: