mysql in latest php build

#1
Our web pages use mysql not mysqli and it seems that after re-installing php, the mysql module doesn't exist anymore.
So our database connections are broken.
How can I get mysql working again?
 

webizen

Well-Known Member
#2
likely you left out the '--with-mysql' option when you re-compile php. to verify, do following from command line and see anything comes up:
/usr/local/lsws/fcgi-bin/lsphp5 -i | grep mysql
if no, you need to rebuild php with that option.
 
#4
I put this in
--with-mysql=/usr/bin --with-libdir=lib64 --with-mysqli --with-zlib --with-gd --enable-shmop --enable-track-vars --enable-sockets --enable-sysvsem --enable-sysvshm --enable-magic-quotes --enable-mbstring --with-iconv --with-litespeed

I read that would help .. and it did allow php to compile.
I restarted the server, but the mysql connections still don't work.

I also have a problem with php includes .. if they are using the full path, they don't work.

Eg this doesn't work

<?php $a = file_get_contents("http://". $_SERVER['HTTP_HOST'] . "/xxx.htm"); echo ($a);?>

But this works

<?php $a = file_get_contents("xxx.htm"); echo ($a);?>
 
#5
I've done what you've suggested with adding --with-mysql=mysqlnd --with-mysqli=mysqlnd
and I added --with-mysql as well.

So the options are currently

--with-mysql=/usr/bin --with-libdir=lib64 --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-mysqli --with-zlib --with-gd --enable-shmop --enable-track-vars --enable-sockets --enable-sysvsem --enable-sysvshm --enable-magic-quotes --enable-mbstring --with-iconv --with-litespeed

My includes work properly now. But my database connections still don't work.

Anything else I can try?
 
#7
I took those out and so had this
--with-libdir=lib64 --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-zlib --with-gd --enable-shmop --enable-track-vars --enable-sockets --enable-sysvsem --enable-sysvshm --enable-magic-quotes --enable-mbstring --with-iconv --with-litespeed

But then after restarting litespeed it didn't help.
 
#8
Here are the error messages I get when trying to connect to mysql ..

Warning: mysql_connect() [function.mysql-connect]: Premature end of data (mysqlnd_wireprotocol.c:553) in /home/xxx/public_html/xxx.php on line 113

Warning: mysql_connect() [function.mysql-connect]: OK packet 1 bytes shorter than expected in /home/xxx/public_html/xxx.php on line 113

Warning: mysql_connect() [function.mysql-connect]: 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 in /home/xxx/public_html/xxx.php on line 113
Cannot connect to the database.
 

webizen

Well-Known Member
#9
...
Warning: mysql_connect() [function.mysql-connect]: 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 in /home/xxx/public_html/xxx.php on line 113
Cannot connect to the database.
Did you try what is suggested (reset mysql user password from mysql admin tool or take out old-password flag from my.cnf)?

if still does not work, try with different php compile option

--with-mysql=/usr --with-pdo-mysql --with-libdir=lib64 --with-zlib --with-gd --enable-shmop --enable-track-vars --enable-sockets --enable-sysvsem --enable-sysvshm --enable-magic-quotes --enable-mbstring --with-iconv --with-litespeed
 
#10
Yes I did reset the password so it was 41 instead of 16 and I also commented out the old-password flag in my.cnf
This didn't help so I went back to an older version of php.

I was still having a problem I mentioned a couple posts back with the php command 'file_get_contents' .. if it is using the full path, it doesn't work.

Eg this doesn't work

<?php $a = file_get_contents("http://". $_SERVER['HTTP_HOST'] . "/xxx.htm"); echo ($a);?>

But this works

<?php $a = file_get_contents("xxx.htm"); echo ($a);?>

So I have rebuilt the entire server from a backup. But after about 5 minutes of working correctly, the problem occurs.

It returns an error message sometimes, not all the time -

Warning: file_get_contents() [function.file-get-contents]: Failure when receiving data from the peer in /home/aaa/public_html/servervars.php on line 20

What can I do?
 
#12
If we restart litespeed, the site includes work for a few minutes, then they start having the same error again.

We thought it may be based on too much traffic, so we only allowed our IP to access the site, and then restarted litespeed, and again it worked for a couple minutes and then broke, just like before.

Is there something that our copy of litespeed has downloaded in the background that would be causing this? We have version 4.1.10
 

webizen

Well-Known Member
#13
was to ask you about this once mysql connection gets resolved.

...
Is there something that our copy of litespeed has downloaded in the background that would be causing this? We have version 4.1.10
don't think that would make any difference.

in just case, pls check if allow_url_open is on in your php setting

/usr/local/lsws/fcgi-bin/lsphp5 -i | grep allow_url
btw, what's your server environment?
 
#14
server environment .. 4cpu linux, 4pcu license litespeed webserver, with a separate mysql database server.

Here's the results of what you asked.
allow_url_fopen => On => On
allow_url_include => Off => Off

So one is on and the other off.
 
#15
Looking at php.info I see the following

php 5.2.11

options -
'./configure' '--disable-pdo' '--enable-bcmath' '--enable-calendar' '--enable-ftp' '--enable-gd-native-ttf' '--enable-libxml' '--enable-magic-quotes' '--enable-sockets' '--prefix=/usr/local' '--with-curl=/opt/curlssl/' '--with-curlwrappers' '--with-freetype-dir=/usr' '--with-gd' '--with-imap=/opt/php_with_imap_client/' '--with-imap-ssl=/usr' '--with-jpeg-dir=/usr' '--with-kerberos' '--with-libdir=lib64' '--with-libxml-dir=/opt/xml2/' '--with-mysql=/usr' '--with-mysql-sock=/var/lib/mysql/mysql.sock' '--with-pic' '--with-png-dir=/usr' '--with-ttf' '--with-xpm-dir=/usr' '--with-zlib' '--with-zlib-dir=/usr' '--with-litespeed'

curl
cURL support enabled
cURL Information libcurl/7.19.7 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5

Maybe something in those values can shed some light on this?
 

webizen

Well-Known Member
#16
Update:

due to file_get_contents(URL), server IP exceeds per client throttling limits (Admin CP -> Server -> Security). hence the problem. once added server IP to allow list (with trailing T), the issue is gone.
 
Top