Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> MySQL

การติดตั้ง MySQL บน macOS

ติดตั้ง MySQL บน macOS ผ่าน package ใน disk image (.dmg) ไฟล์ mount โดย double-click icon ใน Finder

ก่อนติดตั้ง ต้องหยุด MySQL server instances ทั้งหมด (MySQL manager app, preference pane, หรือ mysqladmin shutdown)

ขั้นตอนติดตั้งด้วย Package Installer:

  • ดาวน์โหลด .dmg file (community version available) จาก official website
  • Double-click MySQL installer package บน disk
  • ชื่อไฟล์ขึ้นกับ version เช่น mysql-8.0.22-osx-10.13-x86_64.pkg
  • Wizard intro screen แสดง version ที่จะติดตั้ง
  • Click 'Continue' เริ่มติดตั้ง
  • Community edition แสดง GNU GPL license - Click 'Continue' แล้ว 'Agree'
  • หน้า 'Installation Type': Click 'Install' (defaults) หรือ 'Customize' เลือก components (MySQL server, MySQL Test, Preference Pane, Launchd Support - ทั้งหมดยกเว้น MySQL Test enabled by default)
  • 'Change Install Location' available แต่ไม่สามารถเปลี่ยนได้
  • Click 'Install' ติดตั้ง MySQL Server

หาก upgrade: installation จบตรงนี้ หาก fresh install: ทำ configuration steps ต่อ

  • เลือก default encryption type สำหรับ passwords, enable/disable MySQL server at startup
  • Default MySQL 8.0: caching_sha2_password (Strong)
  • สามารถเปลี่ยนเป็น mysql_native_password (Legacy) ได้
  • Legacy password: เปลี่ยน launchd file ใส่ --default_authentication_plugin=mysql_native_password
  • Strong encryption: ไม่ตั้ง --default_authentication_plugin (ใช้ default caching_sha2_password)
  • ตั้ง password สำหรับ root user, toggle auto-start
  • Summary: การติดตั้งสำเร็จ Close wizard

หากไม่เริ่มตอน startup: ใช้ launchctl command line หรือ click "Start" ใน MySQL preference pane

Files installed ใน /usr/local matching version/platform name เช่น mysql-8.0.25-osx10.15-x86_64.dmg → /usr/local/mysql-8.0.25-osx10.15-x86_64/ พร้อม symlink /usr/local/mysql macOS ไม่สร้าง sample my.cnf