Can phpmyadmin use pdo_mysql to access mysql? - php

My php installed with pdo_mysql, without mysqli/mysql. When I use phpMyAdmin, it showed
"The mysqli|mysql extension is missing".
I tried many times to install mysqli/mysql but failed, and I don't want to re-compile php. So I gave up and chose another mysql web tool Adminer which can use pdo_mysql.
Question : Is it possible that phpMyAdmin use pdo_mysql to access mysql db? I think it should be not hard ,since another tool can.

This information is not immediately available in the online documentation, but the FAQ has it:
phpMyAdmin can connect to your MySQL server using PHP’s classic MySQL extension as well as the improved MySQL extension (MySQLi)
The phrasing is more explicit in their Wiki:
[Requirements]
(...)
Either the mysql or mysqli extensions
(...)
So the answer is: not by default, but contributions are welcome :)

Related

Installing MySQLi shows it will disable MySQL will it affect my current code?

I am trying to install mysqli extension on my server(CENTOS) using WHM Easy Apache 3.
I am selecting mysqli from Exhaustive Options List.
When I select mysqli extension it shows message that this action will disable current mysql extension.
Now, my problem is whether this action will affect my current websites code which is already using mysql extension. I have multiple websites on this server all are built using mysql extension.
I need mysqli for my new website of opencart.
Please help me to understand this warning also let me know if mysql is disabled then can I enable it again and how? so that I can use both mysql & mysqli extensions and my old work will not be affected by this change.
Actually I was in a bit of a hurry, so I took risk to build apache and php using easyapache3 and guess what.... my current code with mysql is not affected at all and both mysql and mysqli extensions are working fine, though I will not recommend to use mysql further to any one, but now I have a time to upgrade my old sites to mysqli and also I am able to use mysqli immediately for my new projects.
Note : when you build apache and php your php.ini might be rewritten by new default settings, so if you have any custom settings in php.ini remember to backup it first and then build apache.
Thanks a lot...

What's the difference between php_pdo_pgsql and php_pgsql PHP extensions?

My default php.ini file lists both extensions (installed via brew), and I sometimes see different variations on Linux (AMZN vs Centos) with the _pdo_ bit. What is the difference?
Update: I was getting errors saying pg_connect not found and this seems to be part of the non-PDO version. To get this installed on Mac via brew, I needed to add support by running brew reinstall php56 --with-postgresql
PDO is short for PHP Data Objects and is an abstraction that can be mapped on to a lot of different databases. This means you can move between things like MySQL, PGSQL and SQLite very easily. The PDO module enables the functions you see here for PGSQL.
The non-PDO module is specific to Postgres and will enable this set of non-standardized functions that will only work with Postgres databases.
The PDO extension can connect to different database management systems with the same syntax, as long as there's a driver for the system you want to use. The PostgreSQL extension can only connecto to PostgreSQL.
What you see is the PostgreSQL extension and the PDO driver for PostgreSQL.

Will installing mysqlnd break existing code in PHP which uses mysql?

I'm moving my code from using mysql in PHP to mysqli. In order to get the mysqli get_result() function to work I need to install mysqlnd as said here on SO. This involves removing the existing php-mysql extension, and now I just want to make sure (those of you who did this) that once I remove the mysql with:
yum remove php-mysql
and install mysqlnd with:
yum install php-mysqlnd
the other code (there's a lot of existing codebase) that uses mysql will still work?
My PHP Version is 5.3.27
With both of php-mysql and php-mysqlnd you have mysql, mysqli and PDO drivers all together. If you just need mysqli driver you already have it with php-mysql.
However if you want migrate to MySQL native driver According to documentation you must pay attention to these:
--The new mysqlnd library necessitates the use of MySQL 4.1's newer
41-byte password format. Continued use of the old 16-byte passwords
will cause mysql_connect() and similar functions to emit the error,
"mysqlnd cannot connect to MySQL 4.1+ using old authentication." The
--new mysqlnd library does not read mysql configuration files
(my.cnf/my.ini), as the older libmysqlclient library does. If your
code relies on settings in the configuration file, you can load it
explicitly with the mysqli_options() function. Note that this means
the PDO specific constants PDO::MYSQL_ATTR_READ_DEFAULT_FILE and
PDO::MYSQL_ATTR_READ_DEFAULT_GROUP are not defined if MySQL support in
PDO is compiled with mysqlnd.
Generally you don't have any problem to migrate from MySQL driver to MySQL native driver. Also it recommended to use php-mysqlnd instead of php-mysql.
I would like to generally answer that NO it's not safe to just remove php-mysql and install php-mysqlnd, especially if you're not "a server guy". Because once I removed php-mysql I removed phpmyadmin along with it and that was quite a disaster.
I ended up (with help of Rackspace server guys) with upgrading my PHP to 5.4 (can't go to 5.5 yet until I convert all my code to use mysqli) and then manually forcing the install of php54-mysqlnd-5.4.17-1.ius.el6.x86_64 (http://dev.mysql.com/downloads/connector/php-mysqlnd/), because of the error while trying to do it "the normal way" Error: php54-mysql conflicts with php54-mysqlnd-5.4.17-1.ius.el6.x86_64. Hope this helps someone.
Also be aware of mysqlnd returning number as numbers, while libmysqlclient (php-mysql) returns all types as string.
So if you use ===, it may give unexpected behavior.
Had a case with mysqlnd in the dev-envirement, and libmysqlclient in the production-envirement, got a few bugs where I compared a string value and an integer value, but on the dev server they was both integers.

WHM enable PHP PDO library

I just switched hosts from a shared to a vps host and I am configuring my WHM account. I want to be able to use the PHP PDO library. I know how to get to the apache update form and locate the pdo section. The only problem is that there are two options, a pdo check box that reads
Includes SQLite support. MySQL support is available. If you plan on installing or updating >PDO drivers (freetds, oracle, etc) via PECL you might want to skip this option as PECL will >install the version of PDO it has. This option will make the following changes to your >profile prior to the build:
Enables:
SQLite3
and a PDO_MYSQL box that reads
This option will make the following changes to your profile prior to the build:
Enables:
PDO
I do not know which option to choose.
The second one, the first is to enable SQLite; I'm guessing you wanna use MySQL ?

mysql_connect() error message

I have installed Apache2.2 and then installed PHP5.4.8. I cannot get my new .php file to load in a browser because it keeps giving me the error Fatal error: Call to undefined function mysql_connect(). When I load the test.php file which has only this in it:
<?php phpinfo(); ?> it returns a page that shows information about PHP but where it would show the MySQL modules it only shows mysqlnd. What is that? Also, I have gone through the php.ini file and uncommented the proper lines for MySQL integration as well as having edited the Apache2.2 httpd file. Does anyone have any answers as to why MySQL isn't working? Thanks in advance.
Also, Ive tried many of the solutions from this website as well as many google searches. I can't seem to figure it out. :-(
1) Have a look on choosing MySQL API. It is recommended to use mysqli extension.
2) According to Other changes to extensions, the MySQL extensions mysql, mysqli and PDO_mysql use mysqlnd as the default library now.
A quote from MySQL Native Driver - mysqlnd site:
Although MySQL Native Driver is written as a PHP extension, it is important to note that it does not provide a new API to the PHP programmer. The programmer APIs for MySQL database connectivity are provided by the MySQL extension, mysqli and PDO MYSQL. These extensions can now use the services of MySQL Native Driver to communicate with the MySQL Server. Therefore, you should not think of MySQL Native Driver as an API.
That means, the mysqlnd extension does not export any function you can use in your scripts, but acts as a bridge between your code and one of mysql, mysqli, pdo_mysql extensions.
You mentioned, that phpinfo() shows only mysqlnd. The fact you don't see section titled MySQL there means that mysql extension is not enabled (commented out) in php.ini (Windows) or your php is not compiled with mysql support (Linux). More details about installing MySQL extension are here.
What is your OS?
To have a successfull MySQL connection you should:
Install the MySQL Server
Configure the PHP to use the proper mysql socket: (in php.ini search for mysql.default_socket - point it to the mysql server).
Reboot the web server - Apache

Categories