Mysql system database missing after install

Installed mysql and phpmyadmin via yast in suse11, but the mysql database hasn’t been created

mysql> show databases;
±-------------------+
| Database |
±-------------------+
| information_schema |
| test |
±-------------------+
2 rows in set (0.00 sec)

In an attempt to fix this I ran: sh /usr/bin/mysql_install_db

This appeared to run ok, amongst other stuff it reported:

Installing MySQL system tables…
OK
Filling help tables…
OK

There still isn’t a mysql database though, uninstalled mysql, rebooted, reinstalled mysql, and there still isn’t a mysql database

I mean the database called mysql, contains the users table etc

How can I create the system database?

It isn’t; you have logged on as a user and it only shows you the databases to which you have access as user.

To see, and access, mysql, you need to log on as root in mysql.

Sorry for the slow reply, a ‘real life’ crisis took precedence

I was logged in as root when I did that john_hudson, using mysql -h localhost -u root

If I try opening phpMyAdmin I get this:

Cannot load mysqli extension. Please check your PHP configuration. - Documentation

The section in the documentation shows this:

1.20 I receive the error “cannot load MySQL extension, please check PHP Configuration”.

To connect to a MySQL server, PHP needs a set of MySQL functions called “MySQL extension”. This extension may be part of the PHP distribution (compiled-in), otherwise it needs to be loaded dynamically. Its name is probably mysql.so or php_mysql.dll. phpMyAdmin tried to load the extension but failed.

Usually, the problem is solved by installing a software package called “PHP-MySQL” or something similar.

According to yast, php-mysql is installed

I’m wondering if something didn’t go wrong with the install process and whether I shouldn’t uninstall and re-install everything

It’s actually php5-mysql, but I assume that’s a typo. If not, then you have been installing foreign packages, naughty naughty.

Put this PHP script in your webserver’s DocumentRoot and browse it:

<?php
phpinfo();
?>

In the output should be a section about mysql and mysqli extensions. If not, then you have not really installed php5-mysql.

Also look in /var/log/apache2/error_log to see if there are any problems.

Definitely looks like it hasn’t installed properly

There’s only stuff about postgresql and sqlite in phpinfo (only references to mysql are ini files), plus a pile of errors in the apache log like:

PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/lib64/php5/extensions/mysql.so’ - /usr/lib64/php5/extensions/mysql.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/lib64/php5/extensions/mysqli.so’ - /usr/lib64/php5/extensions/mysqli.so: cannot open shared object file: No such file or directory in Unknown on line 0

I’ll try uninstalling and reinstalling everything mysql related

It should suffice to install php5-mysql. An install of everything mysql related seems a rather blunt way to deal with the problem.

I had already installed php5-mysql, or to be more precise Yast did when I ran the hhtp server setup thinger in yast’s network services section

I’ve now uninstalled it using yast’s software manager, rebooted and re-installed it through yast, nothing has changed, I’m getting the exact same problem

Any ideas on what else I can try?

Do this and post the output.

rpm -qi php5-mysql

This is to check if you have really installed it and if it’s the right architecture (32/64 bit).

Here ya go mate

Name : php5-mysql Relocations: (not relocatable)
Version : 5.2.6 Vendor: SUSE LINUX Products GmbH, Nuernberg, Germany
Release : 0.4 Build Date: Wed 20 Aug 2008 19:46:40 BST
Install Date: Sun 21 Sep 2008 12:04:41 BST Build Host: baur.suse.de
Group : Development/Libraries/PHP Source RPM: php5-5.2.6-0.4.src.rpm
Size : 212377 License: The PHP License, version 3.1.
Signature : DSA/SHA1, Wed 20 Aug 2008 19:59:49 BST, Key ID a84edae89c800aca
Packager : Submitting Bug Reports - openSUSE
URL : PHP: Hypertext Preprocessor
Summary : PHP5 Extension Module
Description :
PHP functions for access to MySQL database servers.

Authors:

The PHP Group
See [PHP: Credits](http://www.php.net/credits.php) for more details

Distribution: openSUSE 11.0 (X86-64)

Ok, check these things:

/usr/sbin/a2enmod -l

should have php5 in it.

ls /usr/lib64/php5/extensions/mysql*

should output

/usr/lib64/php5/extensions/mysqli.so /usr/lib64/php5/extensions/mysql.so

cat /etc/php5/conf.d/mysql*

should output:

; comment out next line to disable mysqli extension in php
extension=mysqli.so
; comment out next line to disable mysql extension in php
extension=mysql.so

and of course you should have restarted Apache before browsing that page with phpinfo();

/usr/sbin/a2enmod -l
authz_host actions alias auth_basic authz_groupfile authn_file authz_user autoindex cgi dir include log_config mime negotiation setenvif status userdir asis imagemap php5 perl authz_default

php5 is there

ls /usr/lib64/php5/extensions/mysql*
/usr/lib64/php5/extensions/mysqli.so /usr/lib64/php5/extensions/mysql.so

Outputs what you said to expect

cat /etc/php5/conf.d/mysql*
; comment out next line to disable mysqli extension in php
extension=mysqli.so
; comment out next line to disable mysql extension in php
extension=mysql.so

Also outputs what you said to expect

I’ve now got into phpMyAdmin with no errors other than the expected one about no root password being set

But if I log into mysql as root and do show databases; I’m getting this:

mysql> show databases;
±-------------------+
| Database |
±-------------------+
| information_schema |
| test |
±-------------------+
2 rows in set (0.00 sec)

Shouldn’t there be a database called mysql? Or will I not see it until I create a root password?

If I remember rightly I put the root password in my.cnf?

Looks like PHP and the mysql extension are fine.

You’ve probably messed up your MySQL permissions. It’s hard to know exactly what you did but it looks the “root” account in mysql (which has nothing to do with the root account in Linux BTW, other than that the logged in user is the default username when -u is not specified to mysql) doesn’t have permissions on all databases.

If you have nothing of value in MySQL, I would recommend a shutdown of mysql and then a reinstall of all mysql-* packages, but first delete everything under /var/lib/mysql first because a reinstall of mysql packages doesn’t remove the existing databases, for obvious reasons. And read the command line twice before hit return on the rm -fr /var/lib/mysql Oh and also remove my.cnf before the reinstall to start afresh.

Nothing of value in mysql yet mate, the whole suse install is fresh and I’ve not gotten the mysql working properly yet

How I’ve managed to mess up permissions I’ve no idea because all I did is run the yast setup which went without a hitch when I did it in 10.2 and 10.3

Logged into mysql with mysql -h localhost -u root so I should see whatever databases are there (unless I have that wrong)

This is back to the original problem of the mysql database itself not having been created and a reinstall of mysql didn’t fix it, but I didn’t remove the stuff you mentioned first as I expected it to just recreate the database

I’ll give it another go following your instruction

The mysql DB in mysql ought to be there you can look for it as a subdirectory in /var/lib/mysql called mysql of course. If it isn’t there, mysql cannot function as this contains information about what DBs are there, what users are registered, etc. That you cannot see it in the “root” account probably means “root” isn’t powerful enough and somehow some restrictions for “root” were added to the mysql database.

Sometimes mysql databases also get messed up by people who start mysql manually from the command line as root, instead of doing it via the init script /etc/init.d/mysql or the symlink rcmysql or via YaST services configuration. This causes data files to be owned by root rather than the mysql account and therefore inaccessible when mysql is properly started up.

mysql> show databases;
±-------------------+
| Database |
±-------------------+
| information_schema |
| mysql |
| test |
±-------------------+
3 rows in set (0.00 sec)

mysql>

Yay!

Thanks a million ken, you’re a gent and a scholar :slight_smile:

It shows in phpMyAdmin too so that’s it sorted

Thanks again :slight_smile:

Excellent!

It was removing the var/lib/mysql dir that did it, I pretty much knew it was picking up the existing databases on the re-install, but I didn’t know where they ‘live’ in order to get rid of them first

Thanks to you, now I do, once they were gone it was able to recreate the new default ones

As to why they weren’t created properly by yast in the first place I have absolutely no idea