MyBB Community Forums

Full Version: howto use mysql, when only sqlite available
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi.

I wish to use mysqli, but myBB don't detect mysql.

The installation of myBB says:
Supported DB Extensions: SQLite 3

I do have mysql and mysqli installed. I have used them with from PHP before. Currently running mysql v5.1 and PHP v5.3.
Any ideas why myBB don't detect the mysql installation?

Running Centos 5 with root access (if needed).

$ php -i|grep -i mysql
'--with-mysql=shared,mysqlnd' '--with-mysqli=shared,mysqlnd'


$ php -v
PHP 5.3.10 (cli) (built: Feb 4 2012 07:36:51)
Copyright © 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright © 1998-2012 Zend Technologies
$ mysql -V
mysql Ver 14.14 Distrib 5.1.61, for redhat-linux-gnu (x86_64) using readline 5.1
Are you sure the extensions are enabled?
Thanks for the reply, and I was certain, but not anymore... You are right about PHP and MySQL not communicating. I thought the extension would automaticly be enabled after the installation. I even thought I'd used mysql on this server before, but I was wrong. Thanks again for your time. I'll soon write a little troubleshooting guide and solution... if there isn't already enough on this subject.
Ok, then I fixed it and here is what I learned:
First: I am running CentOS 6.2, php5.3 and mysql 5.1

Second:
Requirements for mysqli is mysql v4.1.13 or newer, or 5.0.7 or newer.
You must compile PHP with support for the mysqli extension:
$ php -i | grep with-mysql
You should then get a list of extension enabled for php.

You can easy check if php already are communicating with mysql:
$ php -i | grep mysql*.ini
example output:
/etc/php.d/mysql.ini,
/etc/php.d/pdo_mysql.ini,

If there is no output, you can continue reading and hope for a solution Smile

Issue: PHP couldn't reach my mysql installation
Cause: Not installed php-mysql because of repo remi in centos 6.2 distro.

Troubleshooting: First check if mysql extension is loaded, you can use this script:

<?php
if (extension_loaded('mysqli'))
print_r("Wohoo! PHP can communicate with mysqli.");
else
print_r("Failure! PHP is not running the mysqli extension.");
?>

You can then try and install php-mysql:
# yum install php-mysql

If it says nothing found, then you might have the same error as me. If it says you have installed it, then you need to check if you have a mysql.so or mysqli.so in your module directory. The way I found this:

# find / -name mysql.so

You should have one under */php/modules/mysql.so, if you can't find this, then you probably havan't installed php-mysql.

Sidenote: To find php module directory:
# find / -name modules | grep php
example output: /usr/lib64/php/modules


To check if you have remi repo installed:
$ yum list | grep remi-release
example output: remi-release.noarch 6-1.el6.remi @/remi-release-6

To check if you have remi version of php installed:

$ yum list installed | grep @remi
Example output:
php.x86_64 5.3.10-2.el6.remi @remi
php-bcmath.x86_64 5.3.10-2.el6.remi @remi
php-cli.x86_64 5.3.10-2.el6.remi @remi
php-common.x86_64 5.3.10-2.el6.remi @remi
php-mbstring.x86_64 5.3.10-2.el6.remi @remi
php-pdo.x86_64 5.3.10-2.el6.remi @remi
php-process.x86_64 5.3.10-2.el6.remi @remi
php-xml.x86_64 5.3.10-2.el6.remi @remi


Then it is time to move to my solution, for removing the remi repo and installing php-mysql.


Solution - How to install php-mysql when php version of remi is installed:

The solution is to remove remi repo, downgrade all remi installed packages and then install php-mysql.

Start with removing remi repo:
# yum erase remi-release

Then you need a list of all remi installed packages:
$ yum list installed | grep @remi

Make a note of all the packages and downgrade them all with this command:
#yum downgrade <remi installed packages>
example: # yum downgrade php php-bcmath php-cli php-common php-mbstring php-pdo php-process php-xml

Downgrade all remi installed packages at the same time. I got a few errors when I tried downgrading one by one.

I don't recommend keeping remi packages, since you have removed the repo


Then install php-mysql:
# yum install php-mysql

And after that you can check your php-module directory for mysql.so and mysqli.so:
# find / -name mysql*.so
example output:
/usr/lib64/php/modules/mysql.so
/usr/lib64/php/modules/mysqli.so

Then myBB should be able to find mysql and mysqli... after you restart apache daemon:

To restart apache/http daemon:

# service httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]


More about repos for centos and remi:
CentOS repos: http://wiki.centos.org/AdditionalResources/Repositories
REMI: http://blog.famillecollet.com/pages/Config-en


I hope this will help some in the future, took me a few hours to figure it all out and do it the right way. Thanks for taking the time to read, and just give me feedback if you wish.