Friday, October 27, 2017

How to connect mysql database with laravel

1st to go phpmyadmin
2nd create a database. and go to .evn file, find DB_CONNECTION=mysql line and add database name that you have created on phpmyadmin
3rd user will be root for homeserver

password will be blank like 
DB_DATABASE=your_database_name
DB_USERNAME=root
DB_PASSWORD=


connection is completed.

How i will create a table on laravel database:
go to database >migration 

you can see 2 files 

enter on those file and on those file you can see 3 classes . 1st one is Schema

when we create table we will must use Schema file that's the process on laravel 

there are 2 functions one is up and another is down. with up class table is created and with down function table is dropped 

Which function define with type of table column : go to https://laravel.com/docs/5.5/migrations

you can see Available Column Types table 


How to run Schema file  extrude on server  :
open terminal and write php artisan migrate 



but we can catch an error and exception. 
solve: 
this cause from 5.3 laravel 
when you will make any column unique or index then the total column size must be between 767 bytes 




now you will not get any error and exception. 
see

Thank You.


0 comments:

Post a Comment