Using phpMyAdmin

The tool phpMyAdmin, available from http://www.phpmyadmin.net/, allows you to administer a MySQL database through your web browser. All that's required is a web server with PHP installed and a MySQL database to administer.

To install phpMyAdmin, follow these steps:

1. Click Downloads from the main page.

2. Download the archive file, such as all-languages.tar.gz (Unix archived) or all-languages.zip (Windows ZIP format).

3. Unpack the archive (including subdirectories) to a directory on your computer.

4. Transfer them to your ISP account where PHP files can be executed. Or, if you have a web server installed locally, transfer them to a directory in the document root with a logical name such as myadmin.

5. To configure phpMyAdmin, create a directory called config within the myadmin directory. On Linux systems, execute these commands instead to create the directory, and set the permissions to allow the setup program to modify the configuration file:

cd myadmin mkdir config chmod o+rw config cp config.inc.php config/

chmod o+w config/config.inc.php

6. In your web browser, navigate to http://localhost/myadmin/scripts/setup.php.

You'll see a screen like the one shown in Figure 7-3.

Phpmyadmin Scripts Setup Php

Figure 7-3. The phpMyAdmin setup creates the configuration file for phpMyAdmin

Servers

Figure 7-3. The phpMyAdmin setup creates the configuration file for phpMyAdmin

7. In the Servers section, click the Add button. The Server setup page displays as shown in Figure 7-4.

8. Most of the default values can be left alone. You do need to enter the password for the root MySQL user in the "Password for config auth" field.

9. Select "cookie" from Authentication type to limit access to your MySQL data to only users with a MySQL account.

11. Click "Save" from the Configuration section to save your changes to the configuration file.

12. Copy the config.inc.php file to myadmin.

13. Remove the config directory.

14. In your web browser, navigate to http://localhost/myadmin/index.php. Your web browser displays a login page like the one shown in Figure 7-5.

Index Myadmin
Figure 7-4. Defining the connection details for your MySQL server

15. Enter the usemame root and the password of the root MySQL user to log in to MySQL.

If you're using XAMPP and you get the error "The configuration file now needs a secret passphrase (blowfish_secret)," you'll need to change the line $cfg['blowfish_secret'] = ''; to $cfg['blowfish_ secret'] = 'value'; in the file phpmyadmin/config.inc.php.

Once installed and connected to the database, phpMyAdmin's main page looks similar to the one shown in Figure 7-6.

You can select any configured databases from the drop-down list labeled Databases. The admin provides an easy way to see how your database is configured and what objects exist (such as tables), and you're even offered the option to add tables through the graphical interface. Using PHP admin, you can create new databases and tables, run queries, and display server statistics.

O phpMyAdmin 2.10.0.2 - Moziil j Firefox

anjxj

File Edit Vie1/'.1 History Bookmarks ipols Help

iT" 3 ™ htto://localhost/myadmiri/

i

HI

Google

Welcome to phpMyAdmin 2.10.0.2

Language (D-

English (utt-8)

-Log :n

Username: root

Password:

Go

Figure 7-5. The login page restricts access to your database

Figure 7-7 shows the tables in the test database we'll be creating in this chapter. If your database uses a different name, substitute that name for "test." Click on the authors table on the left to get more details on that table.

Clicking on the authors table displays its table structure. This screen provides an easy way to visualize the layout of a database, particularly if it's a database that you didn't create yourself.

To view the contents of a table, click on the Browse tab. Figure 7-8 shows the Browse tab for the authors table.

The web-based administration tool provides an easy-to-use interface both for exploring your database and creating new objects or for modifying data. You may find the graphical interface to be a refreshing change from the text-based command line of the mysql client.

We're now going to introduce you to basic database structure so that you have an understanding of databases. We'll give you a solid understanding of the language that's used to communicate with the database, SQL. The first step in setting up your database is to create some database tables. Then you'll learn how to add, view, and change data.

) localhost / localhost | phpMyAdmin 2.10.0.2 - Mozilla FirefoH

File Edit View History Bookmarks lools Help

_D.atabas'e

Piease select a database

I' ^ ^ hi:tn: I'lljca hiji"tirriyddTilr/lri:e::::.pihpi^ld-g-erinj:;-;:;I * j Cj J g^ige localhost

Server version: 5.0.37-community-nt

► Protocol version: 10

HSi Server: localhost via TCP/IP

HI MySQL charset: UTF-8 Unicode (utfS) m MySQL connection collation: | utf8_unicode_ci ^ ©

Create new database ©

► Used PHP extensions: mysql Language (D:_

| Collation 3 Create [

9 Show MySQL runtime information © Show MySQL system variables © % Processes © m Character Sets and Collations ^ Storage Engines

Reload privileges © & Privileges

English

9 phpMyAdmin documentation

P phpMyAdmin wiki

<2 Official phpMyAdmin Homepage

Figure 7-6. Selecting a database to administer in phpMyAdmin

) localhost / localhost / test / authors | phpMyAdmio 2.10.0.2 - Mozilla FirefoK

File Edit View History Bookmarks lools Help

■jj*1 I' ^ | pj^ hl:tp://localhosl:ymyadminyindex.php?lang=en-utf-8&token=406d7d42ba [ T | lit* | j |G[w | Google phpNl^dssDsi

3 Server: localhost v jJS Database: test k M[ Table: authors WiffiOHfree: 409&l<B" IgBrowse gf Structure . Search "c insert jjiSxport fig Import

"3

@ authors] @ books @ purchases

^Operations [jf Empty Drop

Field Type Collation

I- author id int(11)

r titlejd int(11)

r author varchar(125) latin 1_swedish_ci t_ Check All / Uncheck All With selected: g

Attributes Null Default Extra

No autojncrei—

Yes NULL

^ Print view ^g Relation view Jli Propose table structure © _

Add [i field(s) f? At End of Table r At Beginning of Table r After | authorjd zl Go it

Figure 7-7. The objects in the test database and the authors table structure

File Edit View History Bookmarks Tools Help s- • •<£ ■■ fB

H autoors g books g purchases

PUA http:/|flocalhost/myadmin/index.phip?lang=en-utf-8Sitoken=4U6d7d' v [>■ | [Gl^|Google gi Server: localhost ► p Database: test y H Table: authors *InnoDB free: 4096 KB" fljBrowse Structure 5fgSQL ^Search Insert jjExport |j Import ^Operations ffgEmpty HjDrop

Q) Showing rows 0 - 3 (4 total, Query took 0.0004 sec)

-SQL query:

SELECT'

FROM authors'

LIMIT 0 30

[ Edit ] [ Explain SQL ] [ Create PHP Code ] [ Refresh ]

-Query results operations-

^ Print view iy*. Print view (with full texts) H Export

Sort by key:

j None'

n

Go |

1P1I

authorjd

titleid

author

r J

X

1

1

EllenSiever

k s

X

g;

1

Aaron Welier

r S

X

H

■Arnold Ri it t i rty

r y

X

4,

■2

rjelsDtt Beetle

mode and repeat headers after |100 cells zi

Figure 7-8. The data in the authors table and the query used to generate it

Was this article helpful?

0 -1

Post a comment