MySQL Help Needed

Discussion in 'Site & Server Administration' started by digitome, Feb 26, 2008.

  1. #1
    I hope someone can help me with this, i am having trouble accessing the SQL databases with PHP scripts. Thing is i can create databases from within cpanel, i can access the database through phpmyadmin and i can write data to the database from within phpmyadmin but i can't get any php script to connect to the database. I have tried several script and none will work.

    Here are some of the server stats:
    CentOS 4.6
    WHM 11.15.0
    Apache 1.3.37
    Cpanel 11.18.1
    PHP 4.4.7
    SQL 4.1.22-standard

    If anyone has any ideas of something i could try i would really appreciate it.
     
    digitome, Feb 26, 2008 IP
  2. boltok

    boltok Active Member

    Messages:
    257
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    78
    #2
    There could be a number of reasons it's not connecting. Can you try connecting to the DB via the mysql command? The syntax would be:

    mysql -u <username> -p <database_name>

    If that works, it means that the database is accepting connections for the above DB via this username. In this case, the issue may be with your scripts.

    In case the above command fails, check the permission and authentication settings for the database.
     
    boltok, Feb 26, 2008 IP
  3. digitome

    digitome Peon

    Messages:
    411
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #3
    It connected without problem like that, but still no luck with scripts. I've tried wordpress and joomla both so i dont see how it could be the scripts themselves?
     
    digitome, Feb 26, 2008 IP
  4. 2WDH.com

    2WDH.com Active Member

    Messages:
    143
    Likes Received:
    3
    Best Answers:
    5
    Trophy Points:
    68
    #4
    Hi Digitome.

    1. What error message do you see when trying to connect to DB from the script?

    2. Did you create MySQL user in cPanel and did you add that user to the database? Or you are trying to connect to the DB from the script with your cPanel username?
     
    2WDH.com, Feb 26, 2008 IP
  5. digitome

    digitome Peon

    Messages:
    411
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Only error message it showed was Unable to Connect to SQL Server. and yeah i did add a user to the database but i tried it both ways with the cpanel username too.

    However i have since installed Apache 2 and PHP5 and it seems to have fixed my problem.
     
    digitome, Feb 26, 2008 IP
  6. rllunzmann

    rllunzmann Active Member

    Messages:
    1,796
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    80
    #6
    have you contacted your host about this? They should be able to resolve this painlessly.
     
    rllunzmann, Feb 27, 2008 IP
  7. suhailc

    suhailc Member

    Messages:
    56
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #7
    Next time this happens to someone, change the MySQL user password to something more secure/complicated and that do the trick!
     
    suhailc, Feb 27, 2008 IP
  8. gate2vn

    gate2vn Peon

    Messages:
    809
    Likes Received:
    33
    Best Answers:
    1
    Trophy Points:
    0
    #8
    I believe the first compile was missing mysql client. Recompiling php again with mysql would resolve the issue. It's not because of the password thing
     
    gate2vn, Feb 27, 2008 IP
  9. agnivo007

    agnivo007 Peon

    Messages:
    4,290
    Likes Received:
    289
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Right, libmysqlclient.so problem happens often...a recompile helps. ;)
     
    agnivo007, Feb 28, 2008 IP
  10. zacharooni

    zacharooni Well-Known Member

    Messages:
    346
    Likes Received:
    20
    Best Answers:
    4
    Trophy Points:
    120
    #10
    Make sure you install mysql-devel to include the mysql headers for php to compile against.
    Easiest way is /scripts/mysqlup --force && /scripts/easyapache
     
    zacharooni, Feb 28, 2008 IP
  11. maestria

    maestria Well-Known Member

    Messages:
    705
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    110
    #11
    Please print the debug message on the same line that you connect to mysql using php.
    it would give you some better idea about the reason for non connectivity.
    Also issue a mysql flush host in case the host has blocked the ip adress with connecting to db.
     
    maestria, Mar 1, 2008 IP