0

I'm trying to have remote access from a web service in PHP, to MySQL data base in a server which is a cluster (1 manager and 2 nodes)

I connected via ssh to the manager and both nodes, and gived permissions to my root user from another ip

grant all privileges on database.* to root@remoteip identified by 'password';
flush privileges;

I'm trying to connect to the database from my web service with the mysqli function

$mysqli = new mysqli(manager ip, root , password , database);
  if (mysqli_connect_errno()) {
       echo "Error";
  }
  else{
      echo "Connected";
  }

But I can't have a connection from my web service. But if I ssh my web service server and connect to MySQL remotely to the manager and nodes, I do have a connection

mysql -u root -p -h managerip
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MySQL connection id is 
Server version: 5.0.95-log Source distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MySQL [(none)]> 
miken32
  • 42,008
  • 16
  • 111
  • 154
  • 1
    Can you use mysql_error() to tell you what the issue is? I think from your description that your sql database is behind a firewall or rejects external connections in which case you can create an SSH tunnel so your php application can speak to your database. – Ne Ma Feb 07 '20 at 22:30
  • @neil No it doesn't work. – Dharman Feb 07 '20 at 22:32
  • Please read https://stackoverflow.com/q/58808332/1839439 – Dharman Feb 07 '20 at 22:32
  • in my error_log file I have "mysqli::__construct(): (HY000/2000): mysqlnd cannot connect to MySQL 4.1+ using the old insecure authentication. Please use an administration tool to reset your password with the command SET PASSWORD = PASSWORD('your_existing_password'). This will store a new, and more secure, hash value in mysql.user. If this user is used in other scripts executed by PHP 5.2 or earlier you might need to remove the old-passwords flag from your my.cnf file" – Samuel Rangel Feb 07 '20 at 22:40

0 Answers0