My system config is Ubuntu 14.04 + XAMPP + Laravel 4 installed
mysql driver is configured on /opt/lampp/htdocs/larva/app/config/database.php
'mysql' => array(
'driver' => 'mysql',
'host' => 'localhost',
'database' => 'db_larva',
'username' => 'root',
'password' => '*****',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => 'tbl_',
),
extension=php_pdo_mysql.dll
create table using
php artisan migrate:make create_users --create=users
which generate 2014_10_02_114459_create_users.php
php artisan migrate:make create_orders --create=orders
create 2014_10_02_054103_create_orders.php
now on terminal what I did
cd /opt/lampp/htdocs/larva/
php artisan migrate
it gives error
[PDOException] could not find driver
when i run
php artisan migrate --database=db_larva
it again gives other error
[InvalidArgumentException]
Database [db_larva] not configured.
Please guide me what I am doing wrong?
My guess:
Is location correct? do run php artisan
inside the root folder?
Default table structure inside function up()
need to write some more code, may be db connection settings
php artisan migrate:make create_users --create=users
and
php artisan migrate:make create_users --create --table=users
I haven't write single line to connect database, anywhere in the code yet. where to write the connection sting in code, or that is a later stage?
php --ini
gives different path of php ini?
Configuration File (php.ini) Path: /etc/php5/cli Loaded Configuration File: /etc/php5/cli/php.ini Scan for additional .ini files in: /etc/php5/cli/conf.d Additional .ini files parsed: /etc/php5/cli/conf.d/05-opcache.ini, /etc/php5/cli/conf.d/10-pdo.ini, /etc/php5/cli/conf.d/20-json.ini, /etc/php5/cli/conf.d/20-mcrypt.ini, /etc/php5/cli/conf.d/20-readline.ini, /etc/php5/cli/conf.d/20-xdebug.ini
I got this error on xubuntu 14.04. I fixed it in 2 steps:
sudo apt-get install php5-mysql
Parameter --database=
is used to choose DB connection. Your DB connection name is mysql
because you have:
'mysql' =>
so you should run this query using:
php artisan migrate --database=mysql
However in app/config/database.php
file there is a line:
'default' => 'mysql',
If you set it to mysql
you don't need to pass --database
parameter when migrate when you want to migrate to default database connection.
php artisan migrate
will be enough
EDIT
In your case you should edit your /etc/php5/cli/php.ini
file to enable PDO extension
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With