简体   繁体   中英

How to use mysql with a local laravel 8 sail installation

I'm studying Laravel 8 and I'm a beginner. I tried installing it via Sail to take advantage of Docker. Terminal:

curl -s "https://laravel.build/learnlaravel" | bash
cd learnlaravel
./vendor/bin/sail up

Now going to localhost I see the Laravel welcome page, everything ok.

if I do:

php artisan migrate

I get this error:

xlf @ MBP16-XLF learnlaravel% php artisan migrate

   Illuminate \ Database \ QueryException

  SQLSTATE [HY000] [2002] No such file or directory (SQL: select * from information_schema.tables where table_schema = learnlaravel and table_name = migrations and table_type = 'BASE TABLE')

  at vendor / laravel / framework / src / Illuminate / Database / Connection.php: 678
    674▕ // If an exception occurs when attempting to run a query, we'll format the error
    675▕ // message to include the bindings with SQL, which will make this exception a
    676▕ // lot more helpful to the developer instead of just the database's errors.
    677▕ catch (Exception $ e) {
  ➜ 678▕ throw new QueryException (
    679▕ $ query, $ this-> prepareBindings ($ bindings), $ e
    680▕);
    681▕}
    682▕

can someone kindly explain to me in simple words what i did wrong or what i should do? is mySQL database already on Docker? how do i log in to create and configure it with the credentials of the.env file? thank you for your understanding and support:)

Try

./vendor/bin/sail artisan migrate

instead of

php artisan migrate

Docs: https://laravel.com/docs/8.x/artisan#laravel-sail

Additionally you can install any database manager and connect to your database with this credentials to view and configure it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM