mysql cannot connect using localhost

Discussion in 'Installation/Configuration' started by fatbear, Jul 9, 2016.

  1. fatbear

    fatbear Member HowtoForge Supporter

    I've hit the problem where the php mysql_connect fails with the mysql_connect function. The cause seems to be related to the fact that "localhost" is treated specially. I'm on CentOS 7.2 and using mariadb-server-5.5.47-1.el7_2.x86_64.

    I've some searching and found articles like this:

    I tried using mysql_connect via instead of localhost in the test from the above link and I was able to connect.
    I just tried installing following the directions for CentOS 7.2:

    After I complete the steps, I note that I'm not able to login and my guess is that the problem is because of the localhost issue. When installing ISPConfig, I did use as the hostname for the database. I also tried resetting the admin password, but that didn't help either:

    UPDATE sys_user SET passwort = md5('admin') WHERE username = 'admin';

    Is there any way to make localhost work? Or else, why do you think I'm not able to login.
  2. fatbear

    fatbear Member HowtoForge Supporter

    Okay, I've found a part of the problem. I noted that the /etc/php.ini was using /var/run/mysqld/mysql.sock for the MySQL socket file. This was wrong as I'm using /var/lib/mysql/mysql.sock as specified in the /etc/my.cnf file.

    I've fixed the /etc/php.ini file and now I can see that I can sucessfully do:

    mysql_connect($host,$user,$password) or die(mysql_error());
    mysql_select_db($database) or die(mysql_error());
    Nevertheless, I'm still not able to login to ISPConfig. Any thoughts?
  3. till

    till Super Moderator Staff Member ISPConfig Developer

    Please post the content of the /etc/hosts file.

Share This Page