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 Dave - February 12, 2024

Hi maxbenk26, 

I can't recreate that issue locally, or rather I can connect with ports such as 3305 when specified after the hostname, but on my WAMP stack doesn't seem to support 3311.

Can you try to connect from PHP directly and see if it works for you?

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

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

$mysqli = new mysqli();
$mysqli->options(MYSQLI_OPT_CONNECT_TIMEOUT, 1);
if (!$mysqli->real_connect($host, $user, $password, null, $port)) {
    die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error());
}

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

Or put through a second level support request and we can take a look: https://www.interactivetools.com/support/request/

Thanks!

Dave Edis - Senior Developer
interactivetools.com

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!