Test PHP connection MySQL

Source: Internet
Author: User
Tags phpinfo

    • I built the lamp on Linux and I tested Apache + PHP earlier.
    • Create a PHP test under the/var/www/html/directory phpinfo.php
[[email protected] ~]# cd/var/www/html///                Enter httpd default Site directory [[email protected] html]# vim phpinfo.php               // Create and edit phpinfo.php<?phpphpinfo ();? >
    • Access, see effects

    • and tested Php+mysql.
    • Create a PHP connection to MySQL test file under the/var/www/html/directory mysql_connect_db.php
[[email protected] html]# vim mysql_connect_db.php          //Create and edit Mysql_connect_db.php<?php$link = mysql_connect (' ', ' root ', ' root '), if (! $link) {die (' Connection failed: '. mysql_error ());} Else{echo ' connection succeeded ';} Mysql_close ($link);? >
    • Access, see effects

    • Problems encountered and their solutions
    • When I write good mysql_connect_db.php save and exit
    • Access, see the effect, the following error

    • Above error obvious password error

    • Another situation
    • Access, see the effect, the following error

    • Workaround:
[[email protected] ~]# Setenforce 0              //temporarily off SELinux


Test PHP connection MySQL

Related Article

Cloud Intelligence Leading the Digital Future

Alibaba Cloud ACtivate Online Conference, Nov. 20th & 21st, 2019 (UTC+08)

Register Now >

Starter Package

SSD Cloud server and data transfer for only $2.50 a month

Get Started >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.