Skip to content

Instantly share code, notes, and snippets.

@mrchrisadams
Created January 28, 2010 15:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrchrisadams/288824 to your computer and use it in GitHub Desktop.
Save mrchrisadams/288824 to your computer and use it in GitHub Desktop.
### Apache is working fine, and php is connecting to the local db too ###
<?php
// set database server access variables:
$host = "localhost";
$user = "root";
$pass = "PASSWORD";
$db = "DATABASE";
// open connection
$connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!");
// select database
mysql_select_db($db) or die ("Unable to select database!");
echo mysql_select_db($db) // returns 1, so we're connecting okay
?>
### Lets try connecting to the remote server
<?php
// set database server access variables:
$host = "localhost";
$user = "root";
$pass = "PASSWORD";
$db = "DATABASE";
// open connection
$connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!");
// select database
mysql_select_db($db) or die ("Unable to select database!");
echo mysql_select_db($db) //
// returns these errors
// Warning: mysql_connect() [function.mysql-connect]: OK packet 6 bytes shorter than expected in /Users/chrisadams/Sites/info.php on line 14
// Warning: mysql_connect() [function.mysql-connect]: mysqlnd cannot connect to MySQL 4.1+ using old authentication in /Users/chrisadams/Sites/info.php on line 14
// Unable to connect!
?php
## The error on the drupal page - Drupal
The mysql error was: mysqlnd cannot connect to MySQL 4.1+ using old authentication
## I can log in to mysql through my local socket fine:
chrisadams@Chris-Adamss-MacBook-Pro ~ > /usr/local/mysql/bin/mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 877
Server version: 5.1.42 MySQL Community Server (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> exit
Bye
### I can also log into the remote socket fine
chrisadams@Chris-Adamss-MacBook-Pro ~ > /usr/local/mysql/bin/mysql -h xxx.xxx.xxx.xxx -u USER -pPASSWORD
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 107
Server version: 5.0.77 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> exit
Bye
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment