Note that there are some explanatory texts on larger screens.

plurals
  1. POI can remotely connect to mySQL database in command line, but not with php script
    text
    copied!<p>The Error: Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[28000] [1045] Access denied for user 'tech'@'localhost' (using password: YES)' in .......</p> <p>I'm able to remotely connect in command line, but not using php, any ideas where to look?</p> <p>Here are the details:</p> <p>Webserver A: 1.1.1.1 holds the php script: <pre><code>$REGIS_DB_SERVER = "2.2.2.2"; //I've tried the IP as well as "pretendhostname.com" $REGIS_DB_NAME = "db_name"; $REGIS_DB_USER = "tech"; // or any other user name $REGIS_DB_PASSWORD = "password"; //connect to db $db = new PDO("mysql:host = $REGIS_DB_SERVER; dbname=$REGIS_DB_NAME; charset=utf8", $REGIS_DB_USER, $REGIS_DB_PASSWORD); print_r($db -&gt; errorInfo()); echo "Connected&lt;br&gt;"; $sql = "CREATE TABLE Test(PersonID int,LastName varchar(255),FirstName varchar(255),Address varcha(255),City varchar(255))"; $result = $db-&gt;query($sql); echo "$result &lt;br&gt;"; ?&gt; </code></pre> <p>Webserver B: 2.2.2.2 holds the mySQL database: Running Ubuntu 11.04</p> <p>in /etc/mysql/my.cnf</p> <pre><code># Instead of skip-networking the default is now to listen only on # localhost which is more compatible and is not less secure. #Commented out to allow remote connections to this database #bind-address = 216.70.81.240 </code></pre> <p>I run <code>mysql&gt; select Host,User from user;</code> and get:</p> <pre><code>+-----------------------+------------------+ | Host | User | +-----------------------+------------------+ | % | root | | 127.0.0.1 | root | | 1.1.1.1 | tech | | localhost | debian-sys-maint | | localhost | root | | localhost | tech | +-----------------------+------------------+ </code></pre> <p><a href="https://stackoverflow.com/questions/11874518/open-port-3306-in-ubuntu-12-04-to-allow-connections-to-mysql-from-any-ip">Open Port 3306 in ubuntu 12.04 to allow connections to mysql from any ip</a> implies it's not an iptable problem and to test out the connection:</p> <p>I ssh-ed into Webserver A 1.1.1.1 and ran:</p> <pre><code>mysql -u tech -p -h 2.2.2.2 Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 200672 Server version: 5.1.63-0ubuntu0.11.04.1 (Ubuntu) </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload