PHP cannot connect to MySQL under Centos7-centos

Source: Internet
Author: User
    1. Describe your problem
      Server local run php index.php can connect MySQL, browser access server cannot connect MySQL

    2. Paste the relevant code
      index.php


  
   
    1. Post error message
      Not currently

    2. Paste the relevant

    1. What methods have been tried still unresolved (attached link)
      Not currently

Reply content:

    1. Describe your problem
      Server local run php index.php can connect MySQL, browser access server cannot connect MySQL

    2. Paste the relevant code
      index.php


  
   
    1. Post error message
      Not currently

    2. Paste the relevant

    1. What methods have been tried still unresolved (attached link)
      Not currently

Create a new file info.php write it in Phpinfo (); Print out detailed information. See if the MySQL extension is loaded first. And then say the rest.

Run the test under the terminal with non-root permissions php index.php To troubleshoot the permissions issue. By the way, the PHP error fully open to see if it was recorded by log

Open the error first to see what is wrong, it looks like death in Mysql_connect

Re-install lamp, now it's ready

The next time you use other resources, you can try this mysql_connect (...) or Die (Mysql_error ());

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.