mysql in latest php build

Discussion in 'PHP' started by stairmaster, Feb 8, 2012.

  1. stairmaster

    stairmaster Member

    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?
  2. webizen

    webizen Well-Known Member

    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:
    if no, you need to rebuild php with that option.
  3. NiteWave

    NiteWave Administrator

    if php version is 5.3 or above, rebuild php by add --with-mysql=mysqlnd --with-mysqli=mysqlnd build parameter.
  4. stairmaster

    stairmaster Member

    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. stairmaster

    stairmaster Member

    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?
  6. NiteWave

    NiteWave Administrator

    remove --with-mysql=/usr/bin --with-mysqli
  7. stairmaster

    stairmaster Member

    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. stairmaster

    stairmaster Member

    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.
  9. webizen

    webizen Well-Known Member

    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

  10. stairmaster

    stairmaster Member

    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?
  11. stairmaster

    stairmaster Member

    FYI This works too

    $a = file_get_contents("/home/aaa/public_html/xxx.html");
    echo $a;
  12. stairmaster

    stairmaster Member

    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
  13. webizen

    webizen Well-Known Member

    was to ask you about this once mysql connection gets resolved.

    don't think that would make any difference.

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

    btw, what's your server environment?
  14. stairmaster

    stairmaster Member

    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. stairmaster

    stairmaster Member

    Looking at 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 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?
  16. webizen

    webizen Well-Known Member


    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.

Share This Page