×ðÁú¿­Ê±¹ÙÍøµÇ¼

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-&gt;connect_error);
}
echo "ÅþÁ¬ÀÖ³É";
?&gt;

µÇ¼ºó¸´ÖÆ

ÈôÊÇÒ»ÇÐ˳Ëì £¬ÄúÓ¦¸Ã»á¿´µ½ “ÅþÁ¬Àֳɔ ÐÂÎÅ¡£

ÒÔÉϾÍÊÇphpstudyÔõÑùÉèÖÃÊý¾Ý¿âµÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí £¬°æȨÕùÒéÓë±¾Õ¾ÎÞ¹Ø £¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í×ðÁú¿­Ê±¹ÙÍøµÇ¼ÂËÓÍ»úÍø¹Ù·½Ì¬¶È £¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ £¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢ £¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢ £¬ÇëÄúÁ¬Ã¦ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎå £¬9:30-18:30 £¬½ÚãåÈÕÐÝÏ¢

QR code
ÍøÕ¾µØͼ