Haɗa MySQL a cikin Laravel- Jagorar Mataki-mataki

Don haɗawa da bayanan MySQL a cikin Laravel, kuna buƙatar samar da bayanin daidaitawa a cikin fayil Laravel ɗin aikin .env. Anan ga cikakken umarnin:

  1. Bude .env fayil ɗin: Buɗe .env fayil ɗin a cikin tushen tsarin Laravel aikin ku.

  2. Sanya haɗin MySQL: Nemo layukan sanyi masu zuwa kuma sabunta su don dacewa da bayanan haɗin MySQL:

    DB_CONNECTION=mysql  
    DB_HOST=your_mysql_host  
    DB_PORT=your_mysql_port  
    DB_DATABASE=your_mysql_database  
    DB_USERNAME=your_mysql_username  
    DB_PASSWORD=your_mysql_password  
    
  3. Ajiye .env fayil ɗin: Da zarar kun sabunta bayanan haɗin, ajiye .env fayil ɗin.

 

Bayan kammala waɗannan matakan, Laravel za a yi amfani da tsarin haɗin haɗin MySQL don haɗawa da yin hulɗa tare da bayanan. Kuna iya amfani da tambayoyin SQL ko yin amfani da Laravel su ORM(Eloquent) don yin aiki tare da bayanan MySQL a cikin aikace-aikacenku.