Adding phpMyAdmin to MySQL

As part of the PHP for i series we will be using a MySQL database as well as the DB2 database to show how to interact with each.

When we installed ZendServer we also took the default MySQL install, once installed we started the servers using the menus provided before starting a QP2TERM session where we set the root password for MySQL. To do this simply start the QP2TERM session CALL QP2TERM, cd to the /usr/local/mysql directory, enter the following command ./bin/mysqladmin -u root password 'yourpassword'.

As we are avid users of phpMyAdmin we installed it in the phpproj virtualhost site so we can manage the MySQL install more effectively. You can download phpmyadmin from sourceforge or one of the mirrors, unzip the code into the base directory of your website (ours is htdocs) before creating the config file. There are a couple of options to create the config file which are explained in the manual, we simply renamed the config.sample.inc.php to config.inc.php and edited the content. As we are only going to use cookies for access we only had to add a blowfish secret in the appropriate section. Dont forget to restart the MySQL servers once you have completed these actions.

To use PHP you point your browser at the appropriate website and add the phpmyadmin directory (http://myserver/phpmyadmin/ in our case because we unzipped the files into phpmyadmin directory the the servers root directory) . You will need to sign in using root and the password you had set earlier. Then create a user called phpuser with a password, create a new database called phpproj and a new table called users. The content of the users table should be the same as the DB2 table except for a new field which we added to the start of the row. This field needs to be of type INT and have the Auto increment flag set and Not NULL. We will use this id for retrieving specific records in a later exercise.

You should now have a table which looks like the following.

Users table in phpmyadmin
Users Table phpMyAdmin view

We will be adding data to the table using the phpusers profile so it is important to set the privileges to the table for the user. We added all privileges but you can decide the best options to suit your environment.

Thats all for this post, next we will be showing how to select a user in the PHPPROJ and display the additional information for each user using both DB2 and MySQL.

Chris…

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.