Microsoft Word - Sam's Teach Yourself MySQL in 21 Days - SAMS.doc

(singke) #1
To manipulate the GRANT tables, you must have the proper authority. To add a user,use
mysql:
INSERT INTO user VALUES("%","mark", password("cougar")
,"Y","Y","Y","Y","Y","Y","Y","Y","Y","Y","Y","Y","Y","Y","Y");

You would then need to give the user access to a database by manipulating the db table.


  1. Revoke the privileges you granted the users you created in exercise 1 by using the
    REVOKE statement.
    REVOKE ALL ON . TO Paul@%;

  2. Delete the users from the database.
    DELETE FROM user WHERE User="Paul" AND Host="%";


Day 18



  1. Go to the crash-me Web site and compare MySQL against your favorite database.


The crash-me Web site is linked to the MySQL Web site. It shows a statistical
comparison of many popular databases.


  1. Create a user-defined function similar to the one in this day.


Implement the function in your MySQL database following the instructions in this day.
To implement your new function, you will have to add this function to the grant tables. To
do this you will use the CREATE FUNCTION statement. The syntax for the CREATE
FUNCTION statement is as follows:
I. CREATE FUNCTION function_name RETURNS return_type
"compiled file name"

After you have added the function to the grant tables, you should be able to use it like
any other intrinsic MySQL function.

Day 19



  1. Write the syntax for checking a table called my_table for deleted blocks.
    isamchk -r my_table

  2. Give the syntax for showing the current list of active threads on a MySQL server.
    mysqladmin -u username -p processlist

  3. Write the function call for encrypting the string 'my string' with the salt in
    'ht1QbxA2IJPhU'.
    SELECT ENCRYPT('my string,','ht');


Day 20



  1. Perform the recovery option of the myisamchk utility on all of the Meet-A-Geek
    tables.


To accomplish this task, type the following command:
I. bin/myisamchk –r *.MYI


  1. Get the specifications for a server to use for the Meet_A_Geek database, knowing
    that this database will be accessed around 10,000 times a day via the Internet.
    MySQL runs best on UNIX-based systems. For the Meet_A_Geek database, a high-end
    UNIX server would be best. But again, this is very subjective. You probably could get
    away with running it on an Intel system running Linux.


Day 21



  1. There are two scripts that you did not create on the flow chart—the Script to display
    items from the Products table and the script to create an order. Create these
    scripts using Perl and the DBI/DBD.


The answer to this question can be found in the Appendix C directory located on the CD-
ROM that accompanies this book.


  1. The same task as the first exercise, but this time use ADO and ODBC.

Free download pdf