Jump to content

[SOLVED] Php5 not connecting to MySQL5


zep

Recommended Posts

I am moving to a dedicated server (yay!) from a shared hosting package, here are the details:

php 5.2.5

mysql 5.0.45

linux fedora

litespeed (apache interchangeable) server

 

I compiled php5 with the following:

--with-mysql --with-mysqli --with-zlib --with-gd --enable-mbstring --with-mhash --with-mcrypt --with-dom --enable-simplexml --with-pdo-mysql --with-iconv --enable-shmop --enable-track-vars --enable-sockets --enable-sysvsem --enable-sysvshm --enable-magic-quotes

 

 

(above verified with phpinfo.php, does litepeed show loaded modules like apache? There is no litespeed info section like apache...)

 

added to the php.ini file :

 

extension=apc.so

extension=suhosin.so

extension=mysql.so

extension=mysqli.so

extension=pdo_mysql.so

extension=pdo.so

extension=php_mysql.so

extension=libmysql.so

 

; Default socket name for local MySQL connects. If empty, uses the built-in

; MySQL defaults.

mysql.default_socket =/var/lib/mysql/mysql.sock

 

my phpinfo is showing the following for MySql:

 

Active Persistent Links 0

Active Links 0

Client API version 5.0.45

MYSQL_MODULE_TYPE external

MYSQL_SOCKET /var/lib/mysql/mysql.sock

MYSQL_INCLUDE -I/usr/include/mysql

MYSQL_LIBS -L/usr/lib/mysql -lmysqlclient

 

My php scripts work like a charm, but they can't connect to MySQL!  I have been drudging through forums looking for something to try, but have not found a solution.  I have thus found this forum, which seems to have the most knowledgeable members.

 

Please lend a sugestion, as I am under the gun to get this done, I really apprecite the help!

Link to comment
https://forums.phpfreaks.com/topic/104729-solved-php5-not-connecting-to-mysql5/
Share on other sites

thanks everyone, it was the code that was the issue, or actually the password I had for the database login (I used the  old pw) sorry about that I have the PW stored in 3 configuration files, one was wrong, Im sorry for wasting your time...

 

anyway, for those of you troubleshooting a similar issue and winding up in this thread try the following script to do a very simple test to the connection, put it in a plain text file (or use you php ide) and save it as anything really (iI used mysql_test.php) slap it on your server and type the location into your browser.

 

<?php
$link = mysql_connect('localhost', 'sbi', 'sbi123');
if (!$link) {
   die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($link);
?>

 

Hope my despair helps somebody!  Again thanks for answering this thread.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.