Laravel prompts "Nosuchfileordirectory solution" when executing the migrate command

Source: Internet
Author: User
This article mainly introduces how Laravel executes the migrate command prompt: Nosuchfileordirectory solution, and analyzes the causes and related solutions for errors when executing the migrate command, for more information about how to execute the migrate command in Laravel, see the following example: No such file or directory. We will share this with you for your reference. The details are as follows:

An error is reported when you use the Laravel command line tool to perform database migration. the error mysql 2002 is displayed,

Check the database configuration. The website front-end can also be opened, indicating that the database can be connected. why?

There are two solutions in Laravel5:

1. add a database configuration item

'mysql' => [  'driver'  => 'mysql',  'host'   => env('DB_HOST', 'localhost'),  'database' => env('DB_DATABASE', 'forge'),  'username' => env('DB_USERNAME', 'forge'),  'password' => env('DB_PASSWORD', ''),  'charset'  => 'utf8',  'collation' => 'utf8_general_ci',  'unix_socket'  => '/Applications/MAMP/tmp/mysql/mysql.sock',  'prefix'  => 'laravel_',  'strict'  => false,],

Here, we add unix_socket, which is the MAMP environment installed on the Mac of the local machine. The path is/Applications/MAMP/tmp/mysql. to view your path, enter the following command in mysql:

Show variables like '% sock % ';

As shown in:

2. Modify. env configuration

This method can only be temporary modification, so that migrate can be executed, and then it must be changed back.

DB_HOST=localhostDB_CONNECTION=mysqlDB_DATABASE=laravelDB_USERNAME=rootDB_PASSWORD=tantengDB_PORT=8889

The temporary modification method is to change DB_HOST to localhost: 8889, that is, add the port number, and then use the artisan command of Laravel5 to execute the migrate operation. However, after the operation is complete, you need to change it back to the previous method, otherwise, the front-end page of the website cannot be connected to the database. the error message "SQLSTATE [HY000] [2005] Unknown MySQL server host" localhost: 8889 "(0) is displayed)

Now, the migrate error of Laravel5 is solved.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.