first post and first mess for me !!
I recently got the italian version of “php mysql novice to ninja”, 5th edition by Kevin Yank… so far I just love the book.
I decided to go through the painful process of setting up everything needed in the manual way… I am kind new to linux, so I figured out that could be a good way to learn…
so I set up a linux mint vm on my win7 laptop. the vm works flawlessly, as far as I can see.
I installed mysql, php and apache according to the instructions found at the end of the book.
I can connect to apache server from the host without problems, I tried to execute some simple php script (input name and check, echo the date … simple things) and they run without problems.
I added a user to connect to mysql from the host (I know it is not really reccomended, but as I told you, it is all about learning) and from the host I can connect to mysql on the vm using mysql workbench.
I hit a wall, thought, when creating my first pdo object, since I get the funny “could not find driver” msg.
I searched both these forums and internet in general for some ideas, but of course the answers are kind of deeper than I can understand. Somewhere I read it is a good idea to echo the result of “phpinfo()”, and I did it. there is a section named “pdo”, a table whose headers is “pdo drivers”… and the table contains only 1 row, that is “sqlite”. funny thing, if I change the php code line I use to create the pdo object, and write sqlite instead of mysql, the error turns from “could not find driver” to “database not found”: of course, I did not set up the database under sqlite, but under mysql…
so guys, I can see the description I gave you of the situation is far from complete… but still, can any1 help or point me in the right direction? as I understand, I should “install mysql driver” for php… Did I get it right? and what is the procedure to install them? has any1 tried the manual installation of apache - mysql -php as explained in the book? can any1 give me any tip?
thanx for your attention
and actually a “mysql_config” file is present under /usr/local/mysql/bin/
about the extension, that is somehow puzzling me. I found a section of php.ini with a bunch of “extension”, and I tried to “uncomment” the extension=php_mysql.dll, but nothing changed, and honestly I was expecting it: dll is related to windows
I tried to add the rows you wrote to me after all those “extension” but nothing really changed.
on the other hand I noticed there is a note before the extension section, it states that if I do not provide a path php is going to search for the extension in the default extension directory.
my phpinfo states
extension_dir /usr/local/php/lib/php/extensions/no-debug-zts-20121212
and if I surf that dir I just find a opcache.so file.
is that the problem? do I have to point at another dir? should I copy the mysql.so extension from somewhere?
if these are n00b questions please forgive me
I thought so so I edited the changes before running the server…
I did something else
if I launch from /usr/local
find . -iname “*.so” -follow
terminal gives me a number of files…
but if I type
find . -iname “mysql.so” -follow
or
find . -iname “pdo.so” -follow
I get nothing in return.
does that mean that I have both php and mysql but I am missing pdo driver for mysql?? =)
well, AFAIK dll are related to windows world, I never “met” a dll extension in linux. but I am kinda new around here, it might just be it a matter of time
something more:
inside
/usr/local/php/include/php/ext
I found both a pdo and a mysqli dir
but they both contain 2 .h file each.
so more and more it seems like I did not install a required package. but the question is: wich one??
one step forward YEES
I added a foreach cycle at the start of the page (nothing special, just copied it from some page around)
for each (PDO::getAvailableDrivers() as $driver)
{
echo “<p>driver:”. $driver .“</p>”;
}
and of course, the only line I got was driver: sqlite
they say mysql driver is natively included into php starting from version 5.5
so I stopped apache,
got into the dir where I had downloaded php
launched
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=mysqlnd --with-pdo-mysql=mysqlnd
make
make install
then I restarted apache… and YES
the page now lists
driver:sqlite
driver: mysql
and the error is no more “could not find driver”
but
“Access denied for user” …
which is still a bit weird, but it seems like a step forward !!
now guys, a couple of questions:
1 is the book to be corrected? should I try to get in touch with mr. Kevin Yank and relate to him my experience?
2 what exactly did I do? why did I have to use the native driver instead of the mysql config??