ÔõÑùÔÚLinuxÉÏ×°ÖúÍÉèÖÃMySQLÊý¾Ý¿â
ÔõÑùÔÚlinuxÉÏ×°ÖúÍÉèÖÃmysqlÊý¾Ý¿â
Ç°ÑÔ£º
MySQLÊÇÒ»ÖÖ¿ªÔ´µÄ¹ØϵÐÍÊý¾Ý¿âÖÎÀíϵͳ£¬ÆÕ±éÓÃÓÚWebÓ¦ÓóÌÐòµÄ¿ª·¢ºÍÖÎÀí¡£ÔÚLinuxϵͳÉÏ×°ÖúÍÉèÖÃMySQL¿ÉÒÔ×ÊÖúÎÒÃǴһ¸ö¸ßЧÎȹ̵ÄÊý¾Ý¿âÇéÐΡ£±¾ÎĽ«ÏÈÈÝÔõÑùÔÚLinuxÉÏ×°ÖúÍÉèÖÃMySQL£¬Í¬Ê±ÌṩÏìÓ¦´úÂëʾÀý¡£
Ò»¡¢×°ÖÃMySQL
·¿ªÖնˣ¬ÊäÈëÒÔÏÂÏÂÁîÒÔ¸üÐÂÈí¼þ°üÁÐ±í£º
sudo apt-get update
ÊäÈëÒÔÏÂÏÂÁîÒÔ×°ÖÃMySQLЧÀÍÆ÷£º
sudo apt-get install mysql-server
ÔÚ×°ÖÃÀú³ÌÖУ¬ÏµÍ³»áÌáÐÑÄúÊäÈëMySQL rootÓû§µÄÃÜÂë¡£ÇëÉèÖÃÒ»¸öÇ¿ÃÜÂ룬²¢È·±£Çмǡ£
¶þ¡¢ÉèÖÃMySQL
Æô¶¯MySQLЧÀÍ£º
sudo service mysql start
ÉèÖÃMySQLÇå¾²ÐÔ£º
sudo mysql_secure_installation
ÔÚÖ´ÐÐÉÏÊöÏÂÁîºó£¬ÏµÍ³»áÒªÇóÄúÊäÈëMySQL rootÃÜÂëÒÔÖ´ÐкóÐø²Ù×÷¡£Æ¾Ö¤ÌáÐÑÖð²½Íê³ÉÇå¾²ÐÔÉèÖá£
Èý¡¢ÅþÁ¬MySQL
·¿ªÖնˣ¬ÊäÈëÒÔÏÂÏÂÁîÒÔÅþÁ¬µ½MySQLÊý¾Ý¿âЧÀÍÆ÷£º
mysql -u root -p
ÔÚÌáÐÑ·ûºóÊäÈëMySQL rootÃÜÂ룬¼´¿ÉÀÖ³ÉÅþÁ¬µ½MySQLЧÀÍÆ÷¡£
ËÄ¡¢½¨ÉèÊý¾Ý¿â
ÅþÁ¬µ½MySQLЧÀÍÆ÷ºó£¬¿ÉÒÔʹÓÃÒÔÏÂÏÂÁÉèеÄÊý¾Ý¿â£º
CREATE DATABASE database_name;
ÆäÖУ¬database_nameΪÄúÏëÒª½¨ÉèµÄÊý¾Ý¿âÃû³Æ¡£
Îå¡¢½¨ÉèÓû§²¢·ÖÅÉȨÏÞ
ʹÓÃÒÔÏÂÏÂÁÉèеÄMySQLÓû§£º
CREATE USER ‘username’@’localhost’ IDENTIFIED BY ‘password’;
ÆäÖУ¬usernameΪÄúÏëÒª½¨ÉèµÄÓû§Ãû£¬passwordΪÄúÏëÒªÉèÖõÄÃÜÂë¡£
ÊÚÓèÐÂÓû§¶ÔÊý¾Ý¿âµÄȨÏÞ£º
GRANT ALL PRIVILEGES ON database_name.* TO ‘username’@’localhost’;
Áù¡¢Í˳öMySQL
ÔÚÅþÁ¬µ½MySQLЧÀÍÆ÷µÄÖÕ¶ËÖУ¬¿ÉÒÔʹÓÃÒÔÏÂÏÂÁîÍ˳öMySQL£º
exit;
Æß¡¢³£ÓÃÏÂÁîʾÀý
ÏÔʾËùÓÐÊý¾Ý¿â£º
SHOW DATABASES;
ʹÓÃÖ¸¶¨Ãü¾Ý¿â£º
USE database_name;
ÏÔʾĿ½ñÊý¾Ý¿âÖеÄËùÓÐ±í£º
SHOW TABLES;
ÏÔʾ±í½á¹¹£º
DESCRIBE table_name;
²åÈëÊý¾Ýµ½±íÖУº
INSERT INTO table_name (column1, column2, column3) VALUES (value1, value2, value3);
°Ë¡¢×ܽá
±¾ÎÄÏÈÈÝÁËÔõÑùÔÚlinuxÉÏ×°ÖúÍÉèÖÃmysqlÊý¾Ý¿â£¬²¢ÌṩÁËÏà¹ØµÄ´úÂëʾÀý¡£Í¨¹ýƾ֤±¾Îĵİ취¾ÙÐвÙ×÷£¬Äú¿ÉÒÔ˳Ëì´î½¨Ò»¸öMySQLÊý¾Ý¿âÇéÐΣ¬²¢ÄÜʹÓó£ÓÃÏÂÁîÔÚÊý¾Ý¿âÖоÙÐвÙ×÷¡£Ï£Íû±¾ÎÄÄܶÔÄúÓÐËù×ÊÖú¡£
²Î¿¼×ÊÁÏ£º
https://dev.mysql.com/doc/mysql-installation-excerpt/5.7/en/linux-installation.html
https://www.mysqltutorial.org/mysql-create-table/
https://www.mysqltutorial.org/mysql-insert-statement.aspx
ÒÔÉϾÍÊÇÔõÑùÔÚLinuxÉÏ×°ÖúÍÉèÖÃMySQLÊý¾Ý¿âµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡