Laravel Homestead- MySQL default credentials and database

后端 未结 1 1765
名媛妹妹
名媛妹妹 2021-02-01 19:27

I have setup Laravel and trying to run the artisan migrate command however I am getting the error below

[PDOException] SQLSTATE[HY000] [2002] Co

1条回答
  •  北海茫月
    2021-02-01 19:31

    Homestead comes with a default database called homestead. Your app can either choose to hook into that database, or you will have to go and make a new database manually. You can either use a GUI (like Sequel Pro on Mac) or perform it via the command line through Vagrant.

    // SSH into the box
    vagrant ssh
    
    // Connect to MySQL as the homestead user (password is: secret)
    mysql -u homestead -p
    
    // Create a new database in MySQL
    CREATE DATABASE your_app_name;
    
    // Leave MySQL
    exit;
    

    You can then migrate the database as usual, php artisan migrate.

    If you need to do this with Postgres instead, it's pretty similar.

    // Connect to Postgres (password is: secret)
    psql -U homestead -h localhost
    
    // Create a new database in Postgres
    CREATE DATABASE your_app_name;
    
    // Leave Postgres
    \q
    

    0 讨论(0)
提交回复
热议问题