尊龙凯时人生就是搏

ÔõÑùÉèÖÃCentOSϵͳÒÔ±£»¤WebÓ¦ÓóÌÐòÃâÊÜSQL×¢Èë¹¥»÷

ÔõÑùÉèÖÃcentosϵͳÒÔ±£»¤webÓ¦ÓóÌÐòÃâÊÜsql×¢Èë¹¥»÷

СÐò£º

Ëæ×Å»¥ÁªÍøµÄÉú³¤£¬WebÓ¦ÓóÌÐòµÄʹÓÃÔ½À´Ô½Æձ飬µ«Í¬Ê±Ò²´øÀ´ÁËWebÓ¦ÓóÌÐòµÄÇå¾²ÎÊÌâ¡£ÆäÖУ¬SQL×¢Èë¹¥»÷ÊÇ×î³£¼ûµÄÒ»ÖÖ¹¥»÷·½·¨¡£ÎªÁ˱£»¤ÎÒÃǵÄWebÓ¦ÓóÌÐò£¬ÎÒÃÇÐèÒª¶ÔCentOSϵͳ¾ÙÐÐһϵÁеÄÉèÖúÍÓÅ»¯¡£±¾ÎĽ«ÏÈÈÝÔõÑùÉèÖÃcentosϵͳÒÔ±£»¤webÓ¦ÓóÌÐòÃâÊÜsql×¢Èë¹¥»÷¡£

×°ÖúÍÉèÖÃWebЧÀÍÆ÷

Ê×ÏÈ£¬ÎÒÃÇÐèҪװÖúÍÉèÖÃÒ»¸ö¿É¿¿µÄWebЧÀÍÆ÷À´ÍйÜÎÒÃǵÄWebÓ¦ÓóÌÐò¡£ÔÚÕâÀÎÒÃÇÑ¡Ôñ³£ÓõÄApacheЧÀÍÆ÷×÷ΪʾÀý¡£ÒÔÏÂÊÇÔÚCentOSÉÏ×°ÖÃApacheЧÀÍÆ÷µÄÏÂÁîʾÀý£º

sudo yum install httpd

µÇ¼ºó¸´ÖÆ

Íê³É×°Öúó£¬ÎÒÃÇÐèÒª¶ÔApache¾ÙÐÐһЩÇå¾²ÉèÖá£Ê×ÏÈ£¬ÎÒÃǽ«½ûÓÃЧÀÍÆ÷ÉϵÄĿ¼ä¯ÀÀ¹¦Ð§£¬ÒÔ±ÜÃâ¹¥»÷Õß»ñÈ¡µ½Ð§ÀÍÆ÷ÉϵÄÃô¸ÐÐÅÏ¢¡£ÒÔÏÂÊÇͨ¹ýÐÞ¸Ähttpd.confÎļþ½ûÓÃĿ¼ä¯ÀÀ¹¦Ð§µÄʾÀý£º

sudo vi /etc/httpd/conf/httpd.conf

µÇ¼ºó¸´ÖÆ

ÔÚÎļþÖÐÕÒµ½ÕâÒ»ÐУº

Options Indexes FollowSymLinks

µÇ¼ºó¸´ÖÆ

ÐÞ¸ÄΪ£º

Options -Indexes FollowSymLinks

µÇ¼ºó¸´ÖÆ

ÉúÑIJ¢Í˳öÎļþ¡£È»ºó£¬ÎÒÃǽ«ÖØÆôApacheЧÀÍÆ÷À´Ê¹ÆäÉúЧ£º

sudo systemctl restart httpd

µÇ¼ºó¸´ÖÆ

ÉèÖÃÊý¾Ý¿âЧÀÍÆ÷

WebÓ¦ÓóÌÐòͨ³£ÐèҪʹÓÃÊý¾Ý¿âÀ´´æ´¢ºÍÖÎÀíÊý¾Ý¡£ÔÚÕâÀÎÒÃÇÑ¡ÔñMySQL×÷ΪÊý¾Ý¿âЧÀÍÆ÷À´´æ´¢ÎÒÃǵÄÊý¾Ý¡£ÒÔÏÂÊÇÔÚCentOSÉÏ×°ÖÃMySQLЧÀÍÆ÷µÄÏÂÁîʾÀý£º

sudo yum install mysql-server

µÇ¼ºó¸´ÖÆ

Íê³É×°Öúó£¬ÎÒÃÇÐèÒª¶ÔMySQL¾ÙÐÐһЩÇå¾²ÉèÖá£Ê×ÏÈ£¬ÎÒÃǽ«½ûÓÃÔ¶³Ì»á¼û£¬Ö»ÔÊÐíÍâµØ»á¼ûÊý¾Ý¿â¡£ÒÔÏÂÊÇͨ¹ýÐÞ¸Ämy.cnfÎļþ½ûÓÃÔ¶³Ì»á¼ûµÄʾÀý£º

sudo vi /etc/my.cnf

µÇ¼ºó¸´ÖÆ

ÕÒµ½ÒÔÏÂÐУº

bind-address = 127.0.0.1

µÇ¼ºó¸´ÖÆ

ÔÚÐÐÇ°Ìí¼Ó×¢ÊÍ·ûºÅ¡°#¡±£¬Ê¹Æä³ÉΪעÊÍÐУº

#bind-address = 127.0.0.1

µÇ¼ºó¸´ÖÆ

ÉúÑIJ¢Í˳öÎļþ¡£È»ºó£¬ÎÒÃǽ«ÖØÆôMySQLЧÀÍÆ÷À´Ê¹ÉèÖÃÉúЧ£º

sudo systemctl restart mysqld

µÇ¼ºó¸´ÖÆ

±àдÇå¾²µÄWebÓ¦ÓóÌÐò´úÂë

ÔÚ±àдWebÓ¦ÓóÌÐò´úÂëʱ£¬ÎÒÃÇÐèÒª½ÓÄÉһЩÇå¾²²½·¥À´±ÜÃâSQL×¢Èë¹¥»÷¡£ÒÔÏÂÊÇһЩ·ÀÓù²½·¥µÄʾÀý´úÂ룺

ʹÓòÎÊý»¯ÅÌÎÊÓï¾ä£ºÔÚÖ´ÐÐSQLÅÌÎÊʱ£¬ÎÒÃÇÓ¦¸ÃʹÓòÎÊý»¯ÅÌÎÊÓï¾ä¶ø²»ÊÇÆ´½Ó×Ö·û´®¡£ÕâÑù¿ÉÒÔ±ÜÃâ¹¥»÷ÕßʹÓöñÒâÊäÈë×¢ÈëÌØÁíÍâSQL´úÂë¡£ÒÔÏÂÊÇÒ»¸öʹÓòÎÊý»¯ÅÌÎÊÓï¾äµÄʾÀý£º

import pymysql

conn = pymysql.connect(host='localhost', user='username', password='password', database='dbname')
cursor = conn.cursor()

sql = "SELECT * FROM users WHERE username = %s"
username = 'admin'
cursor.execute(sql, (username,))

result = cursor.fetchall()

for row in result:
 print(row)

conn.close()

µÇ¼ºó¸´ÖÆ

¶ÔÊäÈë¾ÙÐйýÂ˺ÍÑéÖ¤£ºÔÚÎüÊÕÓû§ÊäÈëʱ£¬ÎÒÃÇÓ¦¸Ã¶ÔÊäÈë¾ÙÐйýÂ˺ÍÑéÖ¤£¬ÒÔÈ·±£ÊäÈëÇкÏÔ¤ÆÚµÄÃûÌúÍÀàÐÍ¡£ÒÔÏÂÊÇÒ»¸öÊäÈë¹ýÂ˺ÍÑéÖ¤µÄʾÀý£º

username = input("ÇëÊäÈëÓû§Ãû£º")

# ¹ýÂ˲»·¨×Ö·û
for char in username:
  if char not in ('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_'):
      username = username.replace(char, '')

# ÑéÖ¤Óû§Ãû³¤¶È
if len(username) > 20:
  username = username[:20]

print("´¦ÀíºóµÄÓû§ÃûΪ£º", username)

µÇ¼ºó¸´ÖÆ

ʹÓÃÇå¾²µÄÊý¾Ý¿â¿â£ºÔÚʹÓÃÊý¾Ý¿â¿âʱ£¬ÎÒÃÇÓ¦¸ÃÑ¡Ôñ¿É¿¿µÄ¿â£¬Èçpymysql»òpsycopg2£¬²¢×èֹʹÓÃÒÑÖª±£´æÇå¾²Îó²îµÄ¿â¡£ÕâЩ¿âͨ³£ÌṩÁËһЩÄÚÖõķÀÓù²½·¥£¬Èç×Ô¶¯×ªÒåÌØÊâ×Ö·ûµÈ¡£

½áÂÛ£º

ͨ¹ýÒÔÉÏÉèÖúʹúÂëÓÅ»¯£¬ÎÒÃÇ¿ÉÒÔÓÐÓõر£»¤ÎÒÃǵÄWebÓ¦ÓóÌÐòÃâÊÜSQL×¢Èë¹¥»÷¡£ËäÈ»£¬ÕâÖ»ÊDZ£»¤²½·¥ÖеÄÒ»²¿·Ö£¬ÎÒÃÇ»¹ÐèÒª¹Ø×¢ÆäËûµÄÇå¾²ÎÊÌ⣬²¢ÊµÊ±¸üкÍά»¤ÏµÍ³¡£Í¨¹ý×ÛºÏÔËÓÃÖÖÖÖÇå¾²²½·¥£¬ÎÒÃÇ¿ÉÒÔ¸üÓÐÓõر£»¤ÎÒÃǵÄWebÓ¦ÓóÌÐòºÍÊý¾ÝµÄÇå¾²¡£

ÒÔÉϾÍÊÇÔõÑùÉèÖÃCentOSϵͳÒÔ±£»¤WebÓ¦ÓóÌÐòÃâÊÜSQL×¢Èë¹¥»÷µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

ÁªÏµ尊龙凯时人生就是搏

18523999891

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

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

QR code
sitemap¡¢ÍøÕ¾µØͼ