Home  >  Article  >  Backend Development  >  Laravel executes the migrate command prompt: No such file or directory solution, laravelmigrate_PHP tutorial

Laravel executes the migrate command prompt: No such file or directory solution, laravelmigrate_PHP tutorial

WBOY
WBOYOriginal
2016-07-12 08:56:50780browse

Laravel executes the migrate command prompt: No such file or directory solution, laravelmigrate

This article describes the example of Laravel executing the migrate command prompt: No such file or directory solution. Share it with everyone for your reference, the details are as follows:

Today, when using the Laravel command line tool to perform database migration operations, an error occurred, prompting a mysql 2002 error, as shown in the figure:

It is correct to check the database configuration. The front desk of the website can also be opened, indicating that it can be connected. What is the reason?

In Laravel5, there are two ways to solve it:

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,
],

The added item here is unix_socket, the MAMP environment installed on the local Mac. The path is /Applications/MAMP/tmp/mysql/mysql.sock. The way to check your own path is to enter the following command in mysql to see it. :

show variables like '%sock%';

As shown below:

2. Modify .env configuration

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

DB_HOST=localhost
DB_CONNECTION=mysql
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=tanteng
DB_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 perform the migrate operation. However, after the operation is completed, you must change it back to the previous writing method, otherwise the website front desk The page cannot be opened and cannot be connected to the database, and the error message is: SQLSTATE[HY000] [2005] Unknown MySQL server host 'localhost:8889' (0)

Okay, this solves the problem of error reporting using Laravel5's migrate.

Reprinted from: Xiaotan Blog http://www.tantengvip.com/2015/12/laravel-migrate-mysql-2000/

Readers who are interested in more information about Laravel can check out the special topics on this site: "Introduction and Advanced Tutorial on Laravel Framework", "Summary of PHP Excellent Development Framework", "Basic Tutorial on Getting Started with Smarty Templates", "php Date and Time" Usage Summary", "php object-oriented programming introductory tutorial", "php string (string) usage summary", "php mysql database operation introductory tutorial" and "php common database operation skills summary"

I hope this article will be helpful to everyone’s PHP program design based on the Laravel framework.

Articles you may be interested in:

  • PHP's Laravel framework combined with MySQL and Redis database deployment
  • Using message queue queue and asynchronous queue in PHP's Laravel framework Method
  • Detailed explanation of usage examples of Trait in Laravel
  • Detailed explanation of the steps to register Facades in Laravel
  • Laravel method to implement automatic dependency injection of constructors
  • Usage of Laravel Caching caching data to reduce database query pressure
  • Making APP interface (API) based on laravel
  • Detailed explanation of the use of Eloquent object-relational mapping in PHP's Laravel framework
  • Laravel framework database CURD Summary of operations and coherent operations
  • In-depth analysis of event operations in PHP's Laravel framework

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1111344.htmlTechArticleLaravel executes the migrate command prompt: No such file or directory solution, laravelmigrate This article describes the example of Laravel executing the migrate command Tip: Solution to No such file or directory...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn