PHP artisan migrate不适用于Laravel项目,但显示错误

时间:2017-05-13 18:10:31

标签: php mysql database xampp laravel-5.4

我是Laravel的某种新手,很抱歉愚蠢的问题。 我在我的Ubuntu 16.04上安装了XAMPP。我创建了一个Laravel项目" myFirstProject"在文件夹" / opt / lampp / htdocs / LaravelProjects"。现在我试图使用这个命令

php artisan migrate

但是它显示了一个错误

[Illuminate\Database\QueryException] could not find driver (SQL: select * from informat ion_schema.tables where table_schema = laravel_test and table_name = migrations)


[PDOException] could not find driver

如何在Laravel项目中使用mysql(与XAMPP一起安装)?

以下是.env文件中的一些代码:

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel_test
DB_USERNAME=root
DB_PASSWORD=

这是来自database.php:

'default' => env('DB_CONNECTION', 'mysql'),
'mysql' => [
        'driver' => 'mysql',
        'host' => env('DB_HOST', '127.0.0.1'),
        'port' => env('DB_PORT', '3306'),
        'database' => env('DB_DATABASE', 'laravel_test'),
        'username' => env('DB_USERNAME', 'root'),
        'password' => env('DB_PASSWORD', ''),
        'unix_socket' => env('DB_SOCKET', ''),
        'charset' => 'utf8mb4',
        'collation' => 'utf8mb4_unicode_ci',
        'prefix' => '',
        'strict' => true,
        'engine' => null,
    ],

1 个答案:

答案 0 :(得分:0)

尝试:

import webbrowser, bs4, requests, re

webPage = requests.get("http://uk.ign.com/games/reviews", headers={'User-
Agent': 'Mozilla/5.0'})

webPage.raise_for_status()

webPage = bs4.BeautifulSoup(webPage.text, "html.parser")

#Me trying different selections to try extract the right part of the page 
webLinks = webPage.select(".item-title")
webLinks2 = webPage.select("h3")
webLinks3 = webPage.select("div item-title")

print(type(webLinks))
print(type(webLinks2))
print(type(webLinks3))
#I think this is where I've gone wrong. These all returning empty lists. 
#What am I doing wrong?


lenLinks = min(5, len(webLinks))
for i in range(lenLinks):
    webbrowser.open('http://uk.ign.com/' + webLinks[i].get('href'))

如果您正在使用sudo apt-get install sqlite php5-sqlite php5-mysql sudo /etc/init.d/apache2 restart 重新启动它。