DirectNET

Data Center Management Solutions including UPS Systems, Data Center Cooling, KVM over IP & IP Power Strips, Server Racks and Server Rack accessories; KVM Switches and KVM Extenders; Rackmount Monitors and Rackmount Keyboards.


NAVIGATION
Home
Store
INSIDE MAC
Television Shows
Broadcast Shows
Daily News Shows
Special Shows
EVENTS
DAILY TIPS
Design
Mac OS X
Mac OS X UNIX
COMMUNITY
Forums
Surveys
NEWS
Current
Press
Archive
FEATURES
Editorial
Dr. Mac
Reviews
Reader Reports
RESOURCES
FAQ
Documentation
Learning Center
MAN pages
Glossary
Tutorials
Tips
Links

OUR PARTNERS

OSXFAQ Mac OS X UNIX Tip-of-the-Day  back to index

MySQL - Add a Database and a User

By Adrian Mayo - Editor - OSXFAQ

Monday's and Tuesday's tips showed how to install MySQL and create the administrative MySQL databases. Today, we look at creating your own database and granting permissions to a new user.

Let's create a database called jan. You need not be the Unix root user, but must be the mysql root user.

$ mysql -u root -p
Enter password:
mysql> create database jan;
Query OK, 1 row affected (0.00 sec)

Then create a user, also but not necessarily called jan, and give that user permissions on the jan database. Type:

mysql> grant all on jan.* to jan@localhost identified by 'jans-password';
Query OK, 0 rows affected (0.00 sec)
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| jan                |
| mysql              |
| test               |
+--------------------+
4 rows in set (0.01 sec)

To view all users (user information is held in the mysql database) type:

mysql> use mysql;
Database changed
mysql> Select * from user\G
...
mysql> quit
Bye
$

Thursday's tip will show how to ensure Apple's Apache-PHP module works with the new database.


Visit the Site of the Book of the Unix Tips:


Discuss this trick in the OSXFAQ Learning Center forum

E-mail your comments or suggestions to webmaster@osxfaq.com


Copyright © 2000-2008 Inside Mac Media, Inc. All rights reserved.
Apple assumes no responsibility with regard to the selection, performance, or use of the products or services. All understandings, agreements, or warranties, if any, take place directly between the vendors and prospective users.
Apple, the Apple logo, Mac, PowerMac G4, PowerMac G5, Xserve, Xserve RAID, PowerBook, iBook, Airport, AirPort Extreme, iMac, eMac, iLife, iMovie, iCal, iPhoto, iTunes, QuickTime, FireWire, iPod, iSight, AppleWorks, Macintosh, Jaguar, Panther, Mac OS, Mac OS X and Mac OS X Server are trademarks of Apple Computer, Inc.