How to create a mysql db with Laravel

前端 未结 6 818
盖世英雄少女心
盖世英雄少女心 2021-02-13 14:50

I\'m using Laravel 5.2. I\'ve setup my first migrations and I want to run them. From the video tutorial it doesn\'t explain how to create a mysql db. I know I can do this man

6条回答
  •  爱一瞬间的悲伤
    2021-02-13 15:08

    If you're not going to use a Vagrant box or virtual machine for local development then you're going to have to install your database driver of choice and then create a new database.

    To do that with MySQL from the command line run:

    $ mysql -uroot -p
    mysql> create database yourDatabaseName;
    

    Then cp .env.example .env and update your database creds.

    DB_CONNECTION=mysql
    DB_HOST=127.0.0.1
    DB_PORT=3306
    DB_DATABASE=yourDatabaseName
    DB_USERNAME=root
    DB_PASSWORD=root 
    

    You'll have set up the username and password to your database when you first installed the driver. After this you may have to php artisan key:generate and/or 'php artisan config:clearbutphp artisan migrate` should work. Below are some tutorial resources you may find helpful:

    Initial database creation and seeding with Laravel 5

    How to install MySQL on OSX

提交回复
热议问题