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

dockerµÄmysqlÔõôÅþÁ¬Íⲿ

ÔÚ docker ÖУ¬ÅþÁ¬ mysql µ½ÍⲿÊý¾Ý¿âµÄÒªÁìÈçÏ£º½¨ÉèÍøÂçÒÔÅþÁ¬ÈÝÆ÷¡£Æô¶¯ mysql ÈÝÆ÷²¢Ö¸¶¨ÍøÂçÃû³Æ¡£ÊÚÓèÍⲿ»á¼ûȨÏÞÒÔÔÊÐíÅþÁ¬¡£Ê¹ÓÃÅþÁ¬×Ö·û¹´Í¨½Óµ½ÍⲿÊý¾Ý¿â¡£

ÔõÑùÅþÁ¬ Docker ÖÐµÄ MySQL µ½ÍⲿÊý¾Ý¿â

ÔÚ Docker ÈÝÆ÷ÖÐÔËÐÐ MySQL ʱ£¬¿ÉÄÜÐèÒªÅþÁ¬µ½ÍⲿÊý¾Ý¿âÒÔʵÏÖÊý¾Ý¹²Ïí»ò»á¼ûÍⲿÊý¾ÝÔ´¡£ÒÔÏÂÊÇÅþÁ¬ Docker ÖÐ MySQL µ½ÍⲿÊý¾Ý¿âµÄÒªÁ죺

1. ½¨ÉèÍøÂç

Docker ÈÝÆ÷ĬÈÏ´¦ÓÚ²î±ðµÄÍøÂç¿Õ¼äÖУ¬Òò´ËÐèÒª½¨ÉèÍøÂçÒÔ±ãÈÝÆ÷Ö®¼äÄܹ»Í¨Ñ¶¡ £¿ÉÒÔʹÓÃÒÔÏÂÏÂÁÉèÍøÂ磺

docker network create my-network

µÇ¼ºó¸´ÖÆ

2. Æô¶¯ MySQL ÈÝÆ÷

ÅþÁ¬µ½ÍⲿÊý¾Ý¿â֮ǰ£¬ÐèÒªÆô¶¯ MySQL ÈÝÆ÷¡£ÒÔÏÂÏÂÁ½¨Éè²¢Æô¶¯ MySQL ÈÝÆ÷£¬Ö¸¶¨ÍøÂçÃû³ÆºÍ̻¶¶Ë¿Ú£º

docker run -d \
    --name mysql \
    --network my-network \
    -p 3306:3306 \
    mysql:5.7

µÇ¼ºó¸´ÖÆ

3. ÊÚÓèÍⲿ»á¼ûȨÏÞ

ĬÈÏÇéÐÎÏ£¬MySQL ÈÝÆ÷½öÔÊÐíÍâµØÅþÁ¬¡£ÐèÒªÊÚÓèÍⲿ»á¼ûȨÏÞÒÔÔÊÐíÆäËûÈÝÆ÷»òÖ÷»úÅþÁ¬¡£Ê¹ÓÃÒÔÏÂÏÂÁîÊÚÓèȨÏÞ£º

docker exec mysql mysql -uroot -p <your-password></your-password>

µÇ¼ºó¸´ÖÆ

ÔÚÏÂÁîÌáÐÑ·ûÏ£º

GRANT ALL PRIVILEGES ON *.* TO 'username'@'%' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;

µÇ¼ºó¸´ÖÆ

ÆäÖУº

username ÊÇÍⲿÓû§µÄÃû×Ö

password ÊÇÍⲿÓû§µÄÃÜÂë

% ÔÊÐíÀ´×ÔÈκÎÖ÷»úµÄÅþÁ¬

4. ÅþÁ¬ÍⲿÊý¾Ý¿â

ʹÓÃÍⲿӦÓóÌÐò»ò¹¤¾ßÀ´ÅþÁ¬µ½ÍⲿÊý¾Ý¿â¡ £¿ÉÒÔʹÓÃÒÔÏÂÅþÁ¬×Ö·û´®£º

mysql -h <external_host> -u <username> -p <password><database_name></database_name></password></username></external_host>

µÇ¼ºó¸´ÖÆ

ÆäÖУº

ÊÇÍⲿÊý¾Ý¿âµÄÖ÷»úÃû»ò IP µØµã

ÊÇÊÚÓèÍⲿ»á¼ûȨÏÞµÄÓû§Ãû

ÊÇÊÚÓèÍⲿ»á¼ûȨÏÞµÄÃÜÂë

ÊÇÒªÅþÁ¬µÄÊý¾Ý¿âµÄÃû³Æ

ÒÔÉϾÍÊÇdockerµÄmysqlÔõôÅþÁ¬ÍⲿµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

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

18523999891

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

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

QR code
ÍøÕ¾µØͼ