1

Hi All, Since I'm a newbie to laravel. First time coming to LARAVEL. I Faced lots of problem regarding command like" php artisan migrate"。

エラーのように、

  • [PDOException]: ドライバーが見つかりませんでした
  • [PDOException]: ソケット経由でローカル MYSQL サーバーに接続できません。

    私は何かのように解決策を探していました。Mr.Bordan は解決策を見つけるのを手伝ってくれました。2 日間、デスクトップの前に座って解決策を見つけました。しかし、残念ながら答えを得ることができませんでした。ここで質問しました。

  • Laravel でローカルの MySQL サーバーに接続できませんでした

  • PHP職人の移行 - Laravel

  • my.cnf ファイルに bind-address が存在しない - Laravel

    だから、私は誰にもそんなに多くの答えを探してほしくありません..私は答えを得ました。ここで私の答えをここにいるすべての人々と共有します。

    以下は私の答えです。

4

1 に答える 1

1

初めに、

 - Find your php.ini file in your system using $ php -i |grep php\.ini command.
   Or, check this https://stackoverflow.com/questions/3057110/where-can-i-find-the-php-ini-for-php-cli
 - Open php.ini file. 
 - And, make sure these lines are present or not.
   a)  extension=mysql.so b) extension=pdo_mysql.so
 - If Yes, remove (;) this before them.
 - If not present, run this command `sudo apt-get install php5-mysql`

次に、php artisan migrateコマンドを入力します。きっとエラーになるよcant connect to local MYSQL server through socket

Now, 
 - Change bind-address from localhost to 127.0.0.1
 - Run `/opt/lampp/bin/php`. 
 - After running this if you get "unable to load dynamic library", remove `php_mssql.dll extension` (for non-windows)
 - If not getting error, come directly to "Project-Name-Folder/config/database.php" file and add this code 'unix_socket'   => '/opt/lampp/var/mysql/mysql.sock',

mysql.sock の完全なパスを見つけて追加します

'mysql' => [
            'driver'    => 'mysql',
            'host'      => env('DB_HOST', 'localhost'),
            'database'  => env('DB_DATABASE', 'danishLara'),
            'username'  => env('DB_USERNAME', 'root'),
            'password'  => env('DB_PASSWORD', ''),
        'unix_socket'   => '/opt/lampp/var/mysql/mysql.sock', //Add this line here
            'charset'   => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix'    => '',
            'strict'    => false,
        ],

このMac での Laravel のセットアップ php artisan 移行エラーを確認してください: No such file or directory

于 2015-09-07T15:56:33.153 に答える