Tuesday, 28 April 2009

Upgrade to Ubuntu 9.04 broke PHPMyAdmin

This morning I was going to do some more work on my photo website, but when I loaded up Ubuntu it said there was an update available to the latest version of Ubuntu. So I installed that, which took ages. While it was installing I checked Juza Nature Forum and the WEX forums.

After Ubuntu had finished updating itself, I found there was a permissions problem with phpMyAdmin. So I did sudo chown -R webapps:webapps /usr/share/phpmyadmin/, which fixed that problem. But now phpMyAdmin was just a blank page. I googled for this, and it seems it can be caused by lots of different things. One of the suggestions was to make sure you have extension=mysql.so in your php.ini file.

I checked whether my main php.ini file had that line in it. It didn't, so I added it and restarted apache sudo /etc/init.d/apache2 restart, but phpMyAdmin was still just a blank page. Lots of people suggested changing stuff in the phpMyAdmin config, but there are lots of different config files, e.g. various different files in /usr/share/phpmyadmin and subfolders, /var/lib/phpmyadmin, /etc/phpmyadmin. I chowned /etc/phpmyadmin to webapps as well, but phpMyadmin was still an empty page.

I restarted, but still got a blank page from phpMyAdmin. So I tried reinstalling phpMyAdmin using the synaptic package manager, and I restarted after doing this as well, but still got a blank page from phpMyAdmin.

After that I read about sudo dpkg-reconfigure phpmyadmin. So I tried that, it did give an error message but looked like it worked okay:

dpkg-reconfigure phpmyadmin
dbconfig-common: writing config to /etc/dbconfig-common/phpmyadmin.conf
*** WARNING: ucf was run from a maintainer script that uses debconf, but
the script did not pass --debconf-ok to ucf. The maintainer
script should be fixed to not stop debconf before calling ucf,
and pass it this parameter. For now, ucf will revert to using
old-style, non-debconf prompting. Ugh!

Please inform the package maintainer about this problem.
Replacing config file /etc/phpmyadmin/config-db.php with new version
granting access to database phpmyadmin for phpmyadmin@localhost: success.
verifying access for phpmyadmin@localhost: success.
creating database phpmyadmin: success.
verifying database phpmyadmin exists: success.
populating database via sql... done.
dbconfig-common: flushing administrative password


But I still got an empty page when loading phpMyadmin. Then I read that you can go to http://localhost/phpmyadmin/setup to configure phpMyAdmin.

I tried that, and got a user/password prompt. After filling it in, I got an Internal Server Error 500. It suggested to check the Server error logs, so I found where they were saved and had a look. It had an error about mysql.so already being loaded, so I changed my php.ini file back to what it was before and deleted all the messages in the error log so it would only have any new ones. Unfortunately I still got the 500 Internal Server Error when trying to access phpMyAdmin/setup, but now no errors were being logged at all, so I couldn't tell what was causing the error.

The config.inc.php and htpasswd.setup files in etc/phpmyadmin both didn't allow access to 'Others', so I changed them to 'read' permission for Others. Now phpMyAdmin/setup would continually ask me for a password.

Edit 2009-05-13: Thanks to Eng. R. Baba for contacting me and saying that you must grant 644 on /etc/phpmyadmin/config-db.php in order to allow "Others" read it, and this fixes the problem.

I deleted the contents of /etc/phpmyadmin/apache.conf and that would now let me get into the phpMyAdminSetup page! Of course, deleting the contents of that file makes phpMyAdmin not very secure, but I don't really care about that in my dev. environment, I just want it to work!

Now, on the phpMyAdminSetup page I was greeted with a whole lotta errors goin' on. I chowned /var/lib/phpmyadmin to webapps, and that cleared the errors. After going through the setup options (there didn't seem to be much to do other than change the connection method from tcp/ip to socket as I had chosen socket when running dpkg-reconfigure phpmyadmin. I went to the phpMyAdmin index page, and it wasn't blank!! I logged in using the username and password I had chosen when running dpkg-reconfigure phpmyadmin, and was greeted with a blank page. D'oh!

I edited the index.php page, and added an echo in there to see where the code was going wrong (if it echoes your statement, then you know the script is exiting further down). It printed my text on the screen, and when I viewed source, it looked like all the page was actually there, just not being rendered by FF. Previously when I'd viewed source on the blank pages it would always be empty.

So I removed my echo and now the page worked properly. Weird. Anyway, I was just glad it was working. Only problem was, none of my databases were showing up. I thought I must need to edit the mysql tables to add my databases and users back in there. Unfortunately I didn't have a backup of what the mysql tables looked like, so I thought I'd have to manually edit them - annoying and tedious. I tried to login as root, but got an error that it wasn't valid or something.

After lots of googling and changing various things I was no closer to being able to login as root. I also found that if I tried to login as root, and then login as the phpmyadmin user, it would also reject the phpmyadmin user, and I would need to clear cookies to be able to login.

So I just changed the phpmyadmin to have the same privileges as root (had to do this in terminal). mysql
GRANT ALL PRIVELEGES ON *.* TO phpmyadmin WITH GRANT OPTION;

When I did that, I could now see all my databases, but still couldn't create new databases or add users. I messed about trying to fix this for a while until I eventually realised that I needed to restart mysql. After doing that, everything seems fine so far.

I also have another problem caused by the upgrade though, PCMan File Manager would no longer open files. If I doubled click or right click on a file and try to open in gedit with it, it will show gedit being open in the bottom pane for a second, but never show the actual gedit window.

Gedit from nautilus works fine, though to edit most files I now have to use terminal, type sudo gedit , and then drag the file from Nautilus to the terminal to be able to edit it. Annoying. I guess I could just do sudo nautilus.

The weather today was cloudy most of the day, with a bit of sun in the afternoon and rain in the evening.

Food
Breakfast: Lime marmalade toast sandwich; cup o' tea.
Lunch: Roma style ham with iceberg lettuce sandwich; banana; Fox's triple; about a vulgar fraction one third of an easter egg; cup o' tea.
Dinner: Cheese and ham quiche; baked beans; mashed potato. Pudding was Rhubarb crumble with froxen cream. Coffee.

7 comments:

Rabih M. Baba said...

Hello,

I already did all your steps, and I'm getting the username/password prompt, but now I'm not able to login, it didn't accept the login information.

I ran sudo dpkg-reconfigure phpmyadmin when I enter the username and password still give the sane error, didn't accept the username and password!

If you have any idea about this issue, don't hesitate to share you information.

Rusty said...

What error does PHPMyAdmin give you, something like:

#1045 - Access denied for user 'phpmyadmin'@'localhost' (using password: YES)

Rabih M. Baba said...

Hello,

No ... I'm able to connect my mysql through:
$ mysql -u root -p
mysql> use mysql;
mysql> show tables;

but still not able to access phpmyadmin through: http://localhost/phpmyadmin < it gives empty page.

and the username/password prompt still appear http://localhost/phpmyadmin/setup "I don't know why and through which username and password I supposed to login"

I ran sudo dpkg-reconfigure phpmyadmin and I assigned username and password as root/root but still not accepted :(

Is there any proper way to solve this issue?

Rusty said...

Try deleting the contents of /etc/phpmyadmin/apache.conf

and then see if you can access http://localhost/phpmyadmin/setup

It shouldn't ask you for a password anymore and should let you access the setup pages.

After going through the setup pages and choosing the correct settings, see if phpmyadmin will work. If it won't, open the index.php file located in /usr/share/phpmyadmin/ in gedit (or another text editor), and add a line in there somewhere reasonably near the top like 'echo "hello";' and see if it works.

Rabih M. Baba said...

do you mean by deleting the content of apache.conf in phpmyadmin directory keeping it blank? if yes so I've been deleted the content of the mentioned file, restarted the apaches and tring to access http://localhost/phpmyadmin/setup
if gives the following error:Not Found
The requested URL /phpmyadmin/setup was not found on this server.
Apache/2.2.11 (Ubuntu) Server at localhost Port 80
I will be glad if you contact me at: rmbaba@gmail.com

Cheers,

vizzkid said...

hi,

i am getting the following error while connecting to phpmyadmin DB : 'Wrong permissions on configuration file, should not be world writable!'..

i have googled the error and tried all the chmods for the config files etc.... but still i get the same error....

can u please help me with this error....

Vishal

Rabih M. Baba said...

Can you email me at: rmbaba@gmail.com in order to solve it, the solution is very easy.