Unknown MySQL server host

6 posts by 2 authors in: Forums > CMS Builder
Last Post: February 15, 2024   (RSS)

By maxbenk26 - February 12, 2024 - edited: February 12, 2024

During installation an error occurs: MySQL Error(2005): Unknown MySQL server host 'X.X.X.X:3311 when I specify MySQL Hostname: X.X.X.X:3311.
CMSB doesn't want to understand the mysql port. And the port must be specified; without it it will not connect.
The old version of CMSB connected without problems, the new one does not (

By maxbenk26 - February 13, 2024 - edited: February 13, 2024

Thanks Dave for the answer.
What you wrote worked to connect:
MySQL successfully connected to: 18.9.14.3 via TCP/IP
But CMSB is not connected during installation

By Dave - February 13, 2024

Hi Maxbenk26, 

Okay, try this code.  It replicates the code in CMSB: 

<?php
header("Content-type: text/plain");

$host     = 'localhost:3311'; // default 3306
$user     = 'username';
$password = 'password';

$mysqli = new mysqli();
$mysqli->options(MYSQLI_OPT_CONNECT_TIMEOUT, 1);
$result = $mysqli->real_connect(
    hostname: $host, // can also contain :port
    username: $user,
    password: $password,
    flags   : 0,
);

// on connect error
if (!$result) {
    die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error());
}

// on success
echo 'MySQL successfully connected to: ' . $mysqli->host_info . "\n";

Mysqli should be able to take a hostname:port string as the 'hostname' argument.

Let me know if this works for you.  

Dave Edis - Senior Developer
interactivetools.com
Thanks Dave. Your script helped me find the problem. Now everything works!

By Dave - February 15, 2024

Hi Maxbenk26,

Okay, great to hear.  Thanks for the update.

Dave Edis - Senior Developer
interactivetools.com