Articles index » General » phpMyAdmin Guide

phpMyAdmin Guide

evil<3 has written this Tutorial / Guide. You may post this anywhere, as long as you give credit and have a link to this article.

Submitted by Lord Le Brand on 05 Jul 2009, 16:10

phpMyAdmin Guide


How to use this tool

What is phpMyAdmin?

phpMyAdmin is a tool that let's you administrate MySQL Databases. This is usefull if you're running a Forum, guestbook, or a different system, that uses Databases.

About this Guide

evil<3 has written this Tutorial / Guide. You may post this anywhere, as long as you give credit and have a link to this article.

Contents

The Guide is split into following Parts:
  1. Download and Installation
  2. Browsing the Database and executing Queries
  3. Creating and Restoring Backups
  4. Final Notes

Before reading this Part, make sure that your host hasn't installed phpmyadmin for you already. Because many Hosts have. Sometimes it's in your Admin Panel / cPanel or at phpmyadmin.yourdomain.com. Just make sure, because in that case you can go right to "2. Browsing the Database and executing Queries".

1. Download and Installation


On the homepage of phpMyAdmin - phpmyadmin.net you can find a Documentation, a Demo, and there's a Downloads Page. There's also a Sourceforge Project Page, with download Links.

On this Downloads Page you can download the latest Version of phpMyAdmin, wich is phpMyAdmin 2.8.1-rc1, but it may be a newer version, as i won't be updating this Guide unless needed. Download the newest version in your prefered format (.zip, .bz2, .gz), and extract the content of the file using a program such as WinRAR or WinZIP.

Now you'll have to start your FTP Client and log in. Upload the phpMyAdmin files to your Webspace, and while it's uploading make a copy of "libraries/config.default.php". Rename this file to "config.inc.php" and Search for following values, and change them:
  • $cfg['Servers'][$i]['host']
  • $cfg['Servers'][$i]['port']
  • $cfg['Servers'][$i]['extension']
  • $cfg['Servers'][$i]['auth_type']
The host will be "Localhost" in most cases. The port can be left blank in most cases. The extension also proberbly doesn't have to be changed. The auth_type should be set to "cookie". After you've made those Changes, you can upload the file to you phpmyadmin root directory on the server where you uploaded it.

Now go to your phpMyAdmin in a webbrowser. You should get following Page:

Image

Enter your SQL Login details into the login page and hit "Go". Then you should get the phpMyAdmin index page. On the left you'll have a Dropdown Menu of Databases, and if you choose one you'll also get a list of Tables.

Here's an exemple of my phpBB Database:

Image

You can see the Default phpBB Tables, and some additional Tables. All have the Table prefix "phpbb_". If you got so far, you're done with the installation! You have just set up your very first phpMyAdmin! :)

Now we have installed phpMyAdmin, and selected a Database. What we have to learn now, is how to use it. I will not explain MySQL here, if you want to learn that, you can look here, or search a Tutorial in google.

2. Browsing the Database and executing Queries


Now we've selected a Database, and we can see what's inside. I want to have a List of all of my phpBB Users. So i click on the Table "phpbb_users" in the left-side table list. This is what i get:

Image

I can't see my Data, i only see the Table Columns. This is because the Mode is set to "Structure" Image. Set it to "Browse", and you'll see the Data in a Table like this:

Showing rows 0 - 12 (13 total, Query took 0.0008 sec)
SQL query:

SELECT *
FROM `phpbb_users`
LIMIT 0 , 30

Followed by something, that will look like this:

Image

I have blurred out some of the information. Have a look at the far right. You'll see that the User level for "eviL&lt;3"(eviL<3) is set to "1". All others have "0". That's because 1 Stands for Admin, 2 for Moderator and 0 for normal User in phpBB.

If i wanted to make "Anonymous" an Admin (never do that, this is just an exemple), i'd go and click on the Image next to his Name. Then we'd get following:

Image

And to make the User an Admin, we could set Image to "1", and hit "Go". Now we would get following Query:

SQL Query:
UPDATE `phpbb_users`
SET `user_active` = '0',
`user_level` = '0',

(...)

WHERE `user_id` = -1
LIMIT 1 ;


Now you might already have understood how a Query is built. You can send your own Query by clicking the Image Button. You'll get a Page such as this one:

Image

So now, let's send a Query that shows all Admins, to check that there's no other Admins. Enter this Code in the Textbox:

Code: Select all
SELECT *
FROM `phpbb_users`
WHERE `user_level`= '1'


This will Give you a List of all Admins. Sometimes you also need to run a Query for installing a MOD, as some Mods use additional Tables. Simply follow the instructions in the MOD File, and you'll be fine :)


Now you know how to use phpMyAdmin!

3. Creating and Restoring Backups


This is very important! If you have a Forum, you'll have to make Backups, because you could lose data. Perhaps your Forum could get hacked, and you would have lost all Data. We don't want that to happen, so how do we backup the Data?

First of all, you'll have to select the Database, that you want to backup. Then click on Image to get to the Backup Page. In the "Export" Section you can "Select All" tables for backup. The Type would be "SQL", or something else, if you're not using an SQL Database. I'd leave all the "SQL Options". The Only thing that i'd do is tick the tickbox next to "Save as file". Now you can hit "Go", and the File will be downloaded to your System. Store it in a secure place, where you will find it again.

It's as simple as that. But what if we need to restore the forums from a backup, because we messed it up. What do we do? We'll have to restore it like this.

Click on Image, and you'll be in the Restore Page. At File to import, you can browse the SQL Backup on your System. When you found it hit "Go".

It may take a while, but do not close the Window. Wait until the Restore is done, and check if it's all working. If you made everything correct, it should be working like before.

Make sure to backup often, as often as possible. At least once a week, and if you have a big forum maybe even a few times Daily. I backup about all 2 days. You can never have enough backups if there's really a Problem, so rather be carefull, than having problems later.

4. Final Notes


I just wrote this Guide, because i didn't have much information on this myself, until i saw it mentioned. I hope it helps people, and encourages them to make tonns of backups.

As already mentioned in the First post: If you want to post this Guide anywhere else, feel free to do so. Just make sure you mention my name, and keep a Link to this Thread.

eviL<3
 

License:

All articles in the knowledge base are licensed under the phpbbmodders beerware-nc license.

Back to category


Articles index » General » phpMyAdmin Guide