php artisan commands say a driver is missing - mysql

Somehow most of my php artisan commands report an error:
C:\Projects\bapestore>php artisan migrate
Illuminate\Database\QueryException
could not find driver (SQL: select * from information_schema.tables where table_schema = bapestore and table_name = migrations and table_type = 'BASE TABLE')
at C:\Projects\bapestore\vendor\laravel\framework\src\Illuminate\Database\Connection.php:669
665| // If an exception occurs when attempting to run a query, we'll format the error
666| // message to include the bindings with SQL, which will make this exception a
667| // lot more helpful to the developer instead of just the database's errors.
668| catch (Exception $e) {
> 669| throw new QueryException(
670| $query, $this->prepareBindings($bindings), $e
671| );
672| }
673|
1 C:\Projects\bapestore\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:70
PDOException::("could not find driver")
2 C:\Projects\bapestore\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:70
PDO::__construct()
I just installed PHP7, Laravel, MAMP, MySQL Workbench locally on my Windows 10 to be able to practice more at home. (Lord, has that been an odyssee..) And now I am trying to connect my database, but the tutorial I follow uses a Mac OS.. so I can't follow the instructions there.
Can anyone understand that error?

You are most likely missing a PHP extension. If you are able to locate your php.ini file, search for extension=mysqli or extension=pdo_mysql extensions. You may need to un-commment them to enable the extensions.

Type in your terminal
php --ini
This command will tell the current path of your php.ini configuration file.
Uncoment the following lines in that file.
extension=php_pdo.dll
extension=php_pdo_mysql.dll

Related

How to access mysql V8 on windows V10 with perl?

I'm mystified that this is so difficult.
(1) With activate state perl v5.26.3 I use ppm.bat and search for mysql and DBD-mysql is missing. As per https://code.activestate.com/ppm/DBD-mysql/ I try
ppm install DBD-mysql
I get:
ppm install failed: Can't find any package that provides DBD-mysql
(2) With the same activestate perl's ppm.bat I see mysqlPP and this does not work with MySQL V8 either:
perl -MDBI -e '$cat=$ENV{"MYSQLDATABASECATALOG"}; $svr=$ENV{"MYSQLHOST"}; $user=$ENV{"DATABASEUSER"}; $pass=$ENV{"DATABASECATALOGPASSWORD"}; my $dbh=DBI->connect("dbi:mysqlPP:database=$cat;host=$svr",$user,$pass,{ RaiseError => 1 }) or die "Cannot connect to $data_source: $DBI::errstr"; my $q=$ARGV[0]; my $sth=$dbh->prepare($q) or die "Cannot prepare statement: $DBI::errstr"; $sth->execute(); ... $sth->finish(); $dbh->disconnect;' "<query goes here>"
DBI connect('database=sqlpocket;host=localhost','sqlpocket',...) failed: #08004Client does not support authentication protocol requested by server; consider upgrading MySQL client at C:/Perl64/site/lib/DBD/mysqlPP.pm line 116.
(3) Strawberry perl is suppose to have DBD for mysql already installed and that does not work either:
perl -MDBI -e '$cat=$ENV{"MYSQLDATABASECATALOG"}; $svr=$ENV{"MYSQLHOST"}; $user=$ENV{"DATABASEUSER"}; $pass=$ENV{"DATABASECATALOGPASSWORD"}; my $dbh=DBI->connect("dbi:mysql:dbname=$cat",$user,$pass,{ RaiseError => 1 }) or die "Cannot connect to $data_source: $DBI::errstr"; my $q=$ARGV[0]; my $sth=$dbh->prepare($q) or die "Cannot prepare statement: $DBI::errstr"; $sth->execute(); ... $sth->finish(); $dbh->disconnect;' "<sql query goes here>"
I get
install_driver(mysql) failed: Can't load 'C:/perlstrawberry/5.30.0.1/perl/vendor/lib/auto/DBD/mysql/mysql.xs.dll' for module DBD::mysql: load_file:The specified module could not be found at C:/Users/2207458/Documents/AppBin/perlstrawberry/5.30.0.1/perl/lib/DynaLoader.pm line 193.
Perhaps a required shared library or dll isn't installed where expected.
This is odd because "C:/perlstrawberry/5.30.0.1/perl/vendor/lib/auto/DBD/mysql/mysql.xs.dll" exists and is accessible.
30 Aug 2019 Update:
I'm sorry, I was trying to be less verbose and got sloppy: I removed the "Users/2207458/Documents/AppBin" from the above file name (but I was not consistent). So C:/perlstrawberry/5.30.0.1/perl/vendor/lib/auto/DBD/mysql/mysql.xs.dll was really c:/Users/2207458/Documents/AppBin/perlstrawberry/5.30.0.1/perl/vendor/lib/auto/DBD/mysql/mysql.xs.dll.
PERL5LIB has never been defined. Does it need to be?
The answer for windows (and apparently linux) is here: Lefred's Blog
I issued this command and reset the password:
alter user 'fred' identified with 'mysql_native_password' by 'mysecurepasswd';
This worked for me using ActiveState Perl v5.4 and mysql 8.0.17-winx64.
Apparently this is a security compromise because we are using an older plugin to compare passwords?

How can I check if a Perl module (DBD::mysql) is properly installed?

I am using XAMPP on Mac OS X Yosemite, and I am trying to communicate with my MySQL database using Perl.
This requires two things: (1) DBI and (2) the mysql driver module, DBD::mysql.
I ran into a lot of trouble installing the DBD::mysql portion. However, after following some instructions online, it now looks like DBD::mysql is installed, but I am skeptical that it has correctly.
In Terminal, when I load up cpan and then type "install DBD::mysql", it responds, "DBD::mysql is up to date (4.032)".
From the looks of it, then, it is installed. However, I am worried that what I've installed is enough for it to say, "Hey, I am installed!", but not enough for it to actually be functional, which would be why I'm having errors show up when I try to connect to my database with Perl:
install_driver(mysql) failed: Can't load '/Library/Perl/5.18/darwin-thread-multi-2level/auto/DBD/mysql/mysql.bundle' for module DBD::mysql: dlopen(/Library/Perl/5.18/darwin-thread-multi-2level/auto/DBD/mysql/mysql.bundle, 1): Library not loaded: libmysqlclient.18.dylib
Referenced from: /Library/Perl/5.18/darwin-thread-multi-2level/auto/DBD/mysql/mysql.bundle
Reason: image not found at /System/Library/Perl/5.18/darwin-thread-multi-2level/DynaLoader.pm line 194.
at (eval 6) line 3.
Compilation failed in require at (eval 6) line 3.
Perhaps a required shared library or dll isn't installed where expected
at login.pl line 9.
Relevant Perl code snippet:
my $dbh = DBI->connect(
"dbi:mysql:dbname=TEST",
"root",
"",
{ RaiseError => 1 },
) or die $DBI::errstr;
I am trying to troubleshoot whether this is a problem with my installation of DBD::mysql, or if it is my Perl code.
How can I verify whether my installation of DBD::mysql is all good? Better yet, how can I stop getting this error?
Thank you.
You could wrap the connect() call into an eval block to catch this error, however you don't have many options left if it crashes, probably just to try and produce a more user-friendly error messsage and then die anyway.
As for why you are getting the error, try checking where libmysqlclient.18.dylib lives on your system. It seems like it was somewhere where it could be found during compilation of the DBD::mysql driver but not during your script's runtime. Assuming it hasn't been accidentially uninstalled, adding its directory to the DYLD_LIBRARY_PATH variable should work. I don't know what config to add the path to to make that addition permanent on OSX though.

Laravel 5.1 - `php artisan migrate` is giving 'PDOException'

I know this is a duplicate question however whatever I tried, unfortunately no luck. (To add, I am using MAMP)
I believe I successfully setup the database connection because, using the registration form (Auth/register), after submitting the form, I was getting the error PDO Exception: Driver not found before, but after changing to my MAMP to PHP 5.5.17 from the default(PHP 5.6.1), I started getting error: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'laravel.users' doesn't exist, which I believe shows that the database connection is working and it's just the 'users table' is not created.
Here starts my problem. When I try to use php artisan migrate or migrate:{anything} in the terminal, it's throwing the error:
[PDOException]
could not find driver
But what I want to do is to use php artisan migrate to be able to create tables and migrate them.
Things I have tried:
I added <?php echo phpinfo(); ?> to if pdo files are successfully installed.
I get the result:
so I think it seems okay.
People were talking about opening /MAMP/bin/php/php5.6.1/conf/php.ini and adding extension=pdo_mysql.so in the code, but I have mine already placed there.
When I try php -i | grep PDO in the project root (/MAMP/htdocs/proj), I got:
PDO
PDO support => enabled
PDO drivers => sqlite
PDO Driver for SQLite 3.x => enabled
php -i | grep Conf and `php --ini also outputs:
Configuration File (php.ini) Path: /Applications/MAMP/bin/php/php5.6.1/conf
Loaded Configuration File: /Applications/MAMP/bin/php/php5.6.1/conf/php.ini but php artisan migrate still throwing the same error
SOLUTION:
I chose MAMP to use version 5.5.17 instead of 5.6.1 in the browser (from MAMP Preferences), however this time terminal was running the 5.6.1. What I did was first checking which PHP command and then, running the nano ~/.bash_profile command; and editing the version document. Now everything is up and running :)
What you see in the browser is that you have PDO enabled for PHP running through apache. But this does not mean you have it enabled for PHP running through CLI (in fact they are using two separate ini files). To confirm that you can try:
php -i | grep PDO
And you will see it is missing or not enabled. So what you need to do is to find which php.ini is using the PHP running through CLI and add the PDO module there:
php -i | grep Conf
It will output something like:
Configuration File (php.ini) Path => /etc/php5/cli
Loaded Configuration File => /etc/php5/cli/php.ini

DBD::MySql initialisation failed: Can't locate object method "driver" via package "DBD::MySql" while using Bio-informatics tool OrthoMCL

I am trying to run the bio-informatics tool OrthoMCL on Ubuntu 12.04. This tool needs a MySQL database for data processing. My SQL database is working well and is version 5.5.34. OrthoMCL contains some Perl scripts to run into command line. When I run a that uses the folowing modules I get the folowing error:
mark#CMBIPC34:~/Bureaublad/OrthoMCL/orthomclSoftware-v2.0.9/bin$ perl orthomclLoadBlast '/home/mark/Bureaublad/my_orthomcl_dir/orthomcl.config' '/home/mark/Bureaublad/my_orthomcl_dir/compliantFasta/similarSequences.txt'
DBD::MySql initialisation failed: Can't locate object method "driver" via package "DBD::MySql" at /usr/local/lib/perl/5.14.2/DBI.pm line 821, <F> line 14.
Perhaps the capitalisation of DBD 'MySql' isn't right. at /home/mark/Bureaublad/OrthoMCL/orthomclSoftware-v2.0.9/bin/../lib/perl/OrthoMCLEngine/Main/Base.pm line 56
The modules are:
use DBI;
use FindBin;
use lib "$FindBin::Bin/../lib/perl";
use OrthoMCLEngine::Main::Base;
use strict;
When I ran this script to test installed modules
use DBI;
print "Available DBI Drivers and Data Sources:\n\n";
#drivers;
my #drivers=DBI->available_drivers('quiet');
my #sources;
foreach my $driver (#drivers) {
print "$driver\n";
#sources=eval { DBI->data_sources($driver) };
if ($#) {
print "\tError: ",substr($#,0,60),"\n";
} elsif (#sources) {
foreach (#sources) {
print "\t$_\n";
}
} else {
print "\tNo known data sources\n";
}
}
I get this result:
Available DBI Drivers and Data Sources:
DBM
DBI:DBM:f_dir=Verwijzing naar Stage-documenten
DBI:DBM:f_dir=my_orthomcl_dir
DBI:DBM:f_dir=Dropbox
DBI:DBM:f_dir=OrthoMCL
DBI:DBM:f_dir=MySQL
DBI:DBM:f_dir=.
DBI:DBM:f_dir=mcl-12-068
ExampleP
dbi:ExampleP:dir=.
File
DBI:File:f_dir=Verwijzing naar Stage-documenten
DBI:File:f_dir=my_orthomcl_dir
DBI:File:f_dir=Dropbox
DBI:File:f_dir=OrthoMCL
DBI:File:f_dir=MySQL
DBI:File:f_dir=.
DBI:File:f_dir=mcl-12-068
Gofer
No known data sources
Multiplex
No known data sources
MySql
Error: DBD::MySql initialisation failed: Can't locate object method
Proxy
No known data sources
Sponge
No known data sources
mysql
DBI:mysql:information_schema
When I try in the command line into downloaded folder DBD-mysql-4.025 I get this errors:
perl Makefile.PL
no error
make
/usr/bin/ld: cannot find -lmysqlclient
collect2: ld gaf exit-status 1 terug
make: *** [blib/arch/auto/DBD/mysql/mysql.so] Fout 1
make test
same error as make
make install
same error as make
I tried also installing by cpan[1]> install DBD::mysql and got this error:
/usr/bin/ld: cannot find -lmysqlclient
collect2: ld gaf exit-status 1 terug
make: *** [blib/arch/auto/DBD/mysql/mysql.so] Fout 1
CAPTTOFU/DBD-mysql-4.025.tar.gz
/usr/bin/make -- NOT OK
Running make test
Can't test without successful make
Running make install
Make had returned bad status, install seems impossible
Failed during this command:
CAPTTOFU/DBD-mysql-4.025.tar.gz : make NO
Where can I find -lmysqlclient, I can't find the file on the hard disk of the computer.
The problem don't occure while running this test perl script:
#!/usr/bin/perl -w
use DBI;
$dbh = DBI->connect('dbi:mysql:orthomcl','root','')
or die "Connection Error: $DBI::errstr\n";
$sql = "show tables";
$sth = $dbh->prepare($sql);
$sth->execute
or die "SQL Error: $DBI::errstr\n";
while (#row = $sth->fetchrow_array) {
print "#row\n";
}
In this case the tables of the database OrthoMCL will be displayed correcty without any error message.
I hope somebody can help me to solve this problem.
"Perhaps the capitalisation of ''MySql'' isn't right."
Does your connect statement use the proper capitalization?
$dbh = DBI->connect("dbi:mysql:...", ...);
Finally I found the solution. The problem was in the config file:
dbConnectString=dbi:MySql:orthomcl:localhost:3306
have to be
dbConnectString=dbi:mysql:orthomcl:localhost:3306

how to enable mysql on php5.... apache 2.2 on windows

So I've uncommented the the *extension=php_mysql.dll* line in the php.ini file and I've also filled in the *extension_dir* and *doc_root* but everytime I try to run a php file with the following code:
<?php
mysql_connect("localhost", "root", "admin") or die(mysql_error());
echo "Connected to MySQL<br />";
?>
I get the following error:
"Fatal error: Call to undefined function mysql_connect() in C:\Program Files\Apache Software Foundation\Apache2.2\vhosts\guestbook\extract.php on line 3"
Does anyone know how to fix this?
Your PHP is enabled - that's what's throwing the error you are seeing.
The problem is with the PHP config. The mysql extension is not loaded.
I've uncommented the the *extension=php_mysql.dll* line
And have you checked the file exists in the specified extension dir and is readable by the webserver?
Have you checked that this is the php.ini file your webserver is using? (try running a script with just a call to phpinfo() in it).
It sounds like you have either not restarted Apache for php.ini changes to take effect, or that you do not have the PHP /ext path in your system PATH variable (or it's set wrong in php.ini).
Consider using a pre-configured and fully set up WAMP package such as:
xampp (free) -
WampDeveloper Pro (commercial) -
WampServer (free)