gpt4 book ai didi

php - 解决方案 "Could not find driver"& "can' t 通过套接字连接到本地 MYSQL 服务器” - Laravel

转载 作者:行者123 更新时间:2023-12-04 18:46:51 25 4
gpt4 key购买 nike

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

错误喜欢,

  • [PDOException]: 找不到驱动程序
  • [PDOException]:无法通过套接字连接到本地 MYSQL 服务器。

    我一直在寻找解决方案。 Mr.Bordan 帮我找到了很多解决方案。 2 天后,我坐在桌面前寻找解决方案。但是,不幸的是,我无法得到答案。
    我在这里问问题。
  • Could not connect to local MySQL server with Laravel
  • php artisan migrate - Laravel
  • bind-address not present in my.cnf file - Laravel

    所以,我不希望任何人搜索这么多答案..我得到了答案。我将在这里与大家分享我的答案。

    下面是我的回答。
  • 最佳答案

    首先,

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

    检查此 Setting up Laravel on a Mac php artisan migrate error: No such file or directory

    关于php - 解决方案 "Could not find driver"& "can' t 通过套接字连接到本地 MYSQL 服务器” - Laravel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32442391/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com