How to access mysql V8 on windows V10 with perl? - mysql

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?

Related

Error using perl module DBD::mysql in ActivePerl 5.28 on Windws10 64bits

I installed the new ActiveState Perl custom build with Perl 5.28 and I added the module (DBD-mysql v4.50). The DBI module is set by default to the ActivePerl 5.28 compilation.
use strict;
use warnings;
use diagnostics;
use DBI;
### INIT DB CONNECTION
my $dbh = DBI->connect("DBI:mysql:database=testdb;host=localhost","root", "XXXX",{'RaiseError' => 1,'mysql_auto_reconnect' => 1});
$dbh->{InactiveDestroy} = 1;
$dbh->{mysql_auto_reconnect} = 1;
then I get the following error:
>perl test.pl
Uncaught exception from user code:
install_driver(mysql) failed: Can't load 'C:/Perl64/lib/auto/DBD/mysql/mysql.dll' for module DBD::mysql: load_file:The specified module could not be found at C:/Perl64/lib/DynaLoader.pm line 193.
at (eval 9) line 3.
Compilation failed in require at (eval 9) line 3.
Perhaps a required shared library or dll isn't installed where expected
at test.pl line 15.
DBI::install_driver("DBI", "mysql") called at C:/Perl64/site/lib/DBI.pm line 660
DBI::connect("DBI", "DBI:mysql:database=testdb;host=localhost", "root", "XXXX", HASH(0x109b408)) called at test.pl line 15
Trying from CPAN directly. Nothing changed.
cpan[2]> install DBD::mysql
DBD::mysql is up to date (4.050).
The file C:/Perl64/lib/auto/DBD/mysql/mysql.dll Exist.
I have seek for information and I tryed to reinstall Perl package from EXE and MSI. I tryed to manually reinstall from CPAN console and many other things but It isn't working at all. Any solution or sugestion?

PDO Exception : Could not find driver. [duplicate]

Does the MySQL-server and PHP5-MySQLi version have to match in order for a connection to be possible? I'm currently receiving the error below: I am running BSD.
"Fatal error: Uncaught exception 'PDOException' with message 'could not find driver'..."
Here is the the connection info:
$info = "mysql:dbname=myDB;host=localhost";
$user = "dbUser";
$pw = "somePW";
return(new PDO($info, $user, $pw));
Here is my MySQL information:
mysql-server-5.5.24
php5-mysqli-5.4.3
I had this same issue on my CentOS install. I had tried to install imagick and hosed my install. When I removed all of my php files and reinstalled something wasn't working right.
I ran:
yum install php-pdo
yum install php-pdo_mysql
After doing those two lines I ran
service httpd restart
and everything came back up and running.
PDO uses database specific drivers to connect to database systems. It looks like you are missing the pdo_mysql driver that is required to connect to a MySQL database. There is some details on installing the driver on the pdo_mysql manual page, or there may be a BSD package that you can use (I am afraid I'm not familiar enough with BSD to offer specific advice).
Thanks to zerkms and John C for pointing me in the right direction. Below are the commands I used to install the driver:
#cd /usr/ports/databases/php5-pdo_mysql
#make install clean
#apachectl restart

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