【问题标题】:Ubuntu 14.04.2 Laravel 4.2.0 PDOException could not find driver MySQLUbuntu 14.04.2 Laravel 4.2.0 PDOException 找不到驱动程序 MySQL
【发布时间】:2015-06-16 23:28:26
【问题描述】:

我没有 10 声望,所以无法添加图片,抱歉。

我希望 Laravel 4.2.0 在我的 Ubuntu 14.04.2 LTS 服务器上运行。

到目前为止我做了什么:

  1. 安装 Ubuntu 14.04.2

  2. sudo apt-get install apache2

  3. sudo apt-get install mysql-server

  4. 安装 Openssl

  5. 安装 libmcrypt

  6. 安装 PHP

       ./configure --with-openssl --with-mcrypt --enable-mbstring --with-pdo-mysql --enable-pdo --with-mysql
    

    制作 进行安装

  7. 从 GitHub 下载 Laravel 4.2.0 zip 文件,解压并通过 WinSCP 传输

  8. 通过

    安装 Laravel 4.2.0

    curl -sS https://getcomposer.org/installer | php php composer.phar 安装

  9. 通过配置/app/config/database.php连接数据库

    'mysql' => 数组( '驱动程序' => 'mysql', '主机' => '本地主机', '数据库' => 'laravel', '用户名' => 'laravel 用户', '密码' => '************', '字符集' => 'utf8', '排序规则' => 'utf8_unicode_ci', '前缀' => '', ),

我得到了这个错误。

PDOException
could not find driver

Open: /var/www/laravel/laravel/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php
     */
    public function createConnection($dsn, array $config, array $options)
    {
        $username = array_get($config, 'username');

        $password = array_get($config, 'password');

        return new PDO($dsn, $username, $password, $options);
    }

我不知道该怎么办。 我google了一天,没有答案。请帮帮我。

我检查了使用php -i|grep PDO 命令启用的 PDO。

结果:

PDO support => enabled
PDO drivers => sqlite, mysql
PDO Drivers for MySQL => enabled
PDO Drivers for SQLite 3.x => enabled

但是我检查了 php.ini,没有像 extension=pdo.so 这样的行 所以我添加了这样的行

[Pdo]
; Whether to pool ODBC connections. Can be one of "strict", "relaxed" or "off"
; http://php.net/pdo-odbc.connection-pooling
;pdo_odbc.connection_pooling=strict

;pdo_odbc.db2_instance_name

[Pdo_mysql]
; If mysqlnd is used: Number of cache slots for the internal result set cache
; http://php.net/pdo_mysql.cache_size
pdo_mysql.cache_size = 2000

; Default socket name for local MySQL connects.  If empty, uses the built-in
; MySQL defaults.
; http://php.net/pdo_mysql.default-socket
pdo_mysql.default_socket=

extension=pdo.so
extension=pdo_sqlite.so
extension=sqlite.so

请帮助我摆脱这种令人沮丧的情况.. 提前感谢您对我的帮助。

【问题讨论】:

  • 将此代码放入您的 routes.php goo.gl/gkZm8V 中。然后转到/phpinfo,请检查 PDO 支持部分是否有mysql

标签: mysql exception ubuntu laravel pdo


【解决方案1】:

这意味着你没有安装扩展。

使用以下方式安装它: sudo apt-get install phpx.x-mysql 其中x.x 是您的 php 版本,例如:php5.6-mysql 或者只是尝试: sudo apt-get install php-mysql

【讨论】:

    猜你喜欢
    • 2016-05-16
    • 1970-01-01
    • 2015-08-12
    • 2017-05-29
    • 2017-02-20
    • 2015-04-08
    相关资源
    最近更新 更多