phpstudyÔõÑùÉèÖÃÊý¾Ý¿â
ÎÊÌ⣺ÔõÑùÔÚ phpstudy ÖÐÉèÖÃÊý¾Ý¿â£¿°ì·¨£ºÆô¶¯ phpstudy¡£ÆôÓà mysql ЧÀÍ¡£½¨ÉèÊý¾Ý¿â¡£½¨ÉèÊý¾Ý¿âÓû§¡£ÊÚÓèÓû§¶ÔÊý¾Ý¿âµÄȨÏÞ¡£ÉèÖà php ÅþÁ¬Êý¾Ý¿â¡£²âÊÔÅþÁ¬¡£
PHPstudy ÖÐÉèÖÃÊý¾Ý¿â
PHPstudy ÊÇÒ»¿î¼¯³ÉÁË PHP¡¢MySQL¡¢Apache µÄ¼¯³É¿ª·¢ÇéÐΡ£ÔÚ PHPstudy ÖÐÉèÖÃÊý¾Ý¿âºÜÊǼòÆÓ£¬ÏÂÃæÊÇÏêϸ°ì·¨£º
1. Æô¶¯ PHPstudy
Ë«»÷×ÀÃæͼ±ê»òÔÚ×îÏȲ˵¥ÖÐÕÒµ½²¢Æô¶¯ PHPstudy¡£
Á¬Ã¦Ñ§Ï°¡°PHPÃâ·ÑѧϰÌõ¼Ç£¨ÉîÈ룩¡±£»
2. ÆôÓà MySQL ЧÀÍ
ÔÚ PHPstudy ½çÃæÖУ¬µã»÷ “MySQL” Ñ¡Ï£¬È»ºóÈ·±£ “MySQL Service” ÒÑÆôÓá£
3. ½¨ÉèÊý¾Ý¿â
µã»÷ “Databases” Ñ¡Ï£¬È»ºóµã»÷ “Add Database” °´Å¥¡£ÔÚ “Êý¾Ý¿âÃû” ×Ö¶ÎÖÐÊäÈëÐÂÊý¾Ý¿âµÄÃû³Æ£¬È»ºóµã»÷ “È·¶¨”¡£
4. ½¨ÉèÊý¾Ý¿âÓû§
µã»÷ “Users” Ñ¡Ï£¬È»ºóµã»÷ “Add User” °´Å¥¡£ÔÚ “Óû§Ãû” ºÍ “ÃÜÂë” ×Ö¶ÎÖÐÊäÈëеÄÓû§ÃûºÍÃÜÂ롣ȷ±£Ñ¡ÖÐ “ÊÚÓèËùÓÐȨÏÞ” ¸´Ñ¡¿ò£¬È»ºóµã»÷ “È·¶¨”¡£
5. ÊÚÓèÓû§¶ÔÊý¾Ý¿âµÄȨÏÞ
»Øµ½ “Databases” Ñ¡Ï£¬Ñ¡ÖÐÄú½¨ÉèµÄÐÂÊý¾Ý¿â¡£È»ºó£¬ÔÚ “Users” Ñ¡ÏÖУ¬¹´Ñ¡ “ÕʺŔ ÁÐÖÐÐÂÓû§µÄ¸´Ñ¡¿ò£¬²¢È·±£ “ÊÚÓèȨÏÞ” ÁÐÖÐÏÔʾ “ËùÓÐȨÏÞ”¡£
6. ÉèÖà PHP ÅþÁ¬Êý¾Ý¿â
ÔÚ PHPstudy µÄ¸ùĿ¼ÏÂÕÒµ½ php.ini Îļþ²¢ÓÃÎı¾±à¼Æ÷·¿ªËü¡£ÕÒµ½ÒÔÏÂÐУº
; MySQL ÉèÖÃÑ¡Ïî ; mysql.default_socket = mysql.default_host = 127.0.0.1 mysql.default_user = root mysql.default_password = mysql.default_port = 3306
µÇ¼ºó¸´ÖÆ
½«ÒÔÏÂÄÚÈÝÌ滻ΪÒÔÏÂÄÚÈÝ£º
mysql.default_socket = mysql.default_host = 127.0.0.1 mysql.default_user = еÄÓû§Ãû mysql.default_password = еÄÃÜÂë mysql.default_port = 3306
µÇ¼ºó¸´ÖÆ
ÉúÑIJ¢¹Ø±Õ php.ini Îļþ¡£
7. ²âÊÔÅþÁ¬
ÔÚÄúµÄ PHP ´úÂëÖÐʹÓÃÒÔÏ´úÂë²âÊÔÓëÊý¾Ý¿âµÄÅþÁ¬£º
<?php $servername = "127.0.0.1"; $username = еÄÓû§Ãû; $password = еÄÃÜÂë; $dbname = еÄÊý¾Ý¿âÃû; // ½¨ÉèÅþÁ¬ $conn = new mysqli($servername, $username, $password, $dbname); // ¼ì²éÅþÁ¬ if ($conn->connect_error) { die("ÅþÁ¬Ê§°Ü: " . $conn->connect_error); } echo "ÅþÁ¬ÀÖ³É"; ?>
µÇ¼ºó¸´ÖÆ
ÈôÊÇÒ»ÇÐ˳Ë죬ÄúÓ¦¸Ã»á¿´µ½ “ÅþÁ¬Àֳɔ ÐÂÎÅ¡£
ÒÔÉϾÍÊÇphpstudyÔõÑùÉèÖÃÊý¾Ý¿âµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡