1. Home
  2. Computing & Technology
  3. Linux

Linux Newbie Administrator Guide

From Authors, About.com Guest

8.5.3 Querying the MySQL database

There are many ways to query the MySQL database using the SELECT command. A basic syntax for SELECT would look like this:

SELECT [columns_to_display] FROM [table] WHERE [column] [LIKE] [match_sequence]

For example, using the following command I can search the "age" column and output the information in the "columns_to_display" for the people in their 20's. Note, the "*" selects all the available columns in the table.

mysql> SELECT * FROM my_table WHERE age LIKE "2%";

MySQL databases can also be queried remotely by other applications (for example MS Access). To allow access for other systems to query your database, you can use the GRANT command. To give yourself permission to access the database from multiple domains, alter the DOMAIN_I_WILL_BE_ACCESSING_FROM and run the command again.

mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER

-> ON my_database.* TO peter@DOMAIN_I_WILL_BE_ACCESSING_FROM

-> IDENTIFIED BY 'peters_password';

* License

* Linux Newbie Administrator Guide Index

Explore Linux
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Linux
  4. Linux Documentation
  5. Newbie Administrator Guide
  6. Linux Newbie Administrator Guide - 8.5 RunningMySQL

©2009 About.com, a part of The New York Times Company.

All rights reserved.