2 # $Id: sample_database.sql,v 1.2 2004/07/21 17:52:10 cinergi Exp $
4 # THIS DATABASE IS INTENDED FOR Linux
6 # Use 'mysql -u root -p < sample_database.sql' to load this example into your
9 # 1) create a database called 'auth'
10 # 2) add three tables: 'users', 'groups' and 'grouplist'
11 # 3) add some data to each table
12 # 4) create two MySQL users ('nss-user' and 'nss-root') with appropriate
15 # With a properly-functioning libnss-mysql, you should be able to log into
16 # the system as 'cinergi' with a password of 'cinergi'. 'cinergi' should be
17 # a member of the group 'foobaz' as well.
19 # This is intended as an *example* and is perhaps not the best use of
20 # datatypes, space/size, data normalization, etc.
28 name varchar(16) NOT NULL default '',
29 password varchar(34) NOT NULL default 'x',
30 gid int(11) NOT NULL auto_increment,
32 ) TYPE=MyISAM AUTO_INCREMENT=5000;
34 CREATE TABLE grouplist (
35 rowid int(11) NOT NULL auto_increment,
36 gid int(11) NOT NULL default '0',
37 username char(16) NOT NULL default '',
42 username varchar(16) NOT NULL default '',
43 uid int(11) NOT NULL auto_increment,
44 gid int(11) NOT NULL default '5000',
45 gecos varchar(128) NOT NULL default '',
46 homedir varchar(255) NOT NULL default '',
47 shell varchar(64) NOT NULL default '/bin/bash',
48 password varchar(34) NOT NULL default 'x',
49 lstchg bigint(20) NOT NULL default '1',
50 min bigint(20) NOT NULL default '0',
51 max bigint(20) NOT NULL default '99999',
52 warn bigint(20) NOT NULL default '0',
53 inact bigint(20) NOT NULL default '0',
54 expire bigint(20) NOT NULL default '-1',
55 flag bigint(20) unsigned NOT NULL default '0',
57 UNIQUE KEY username (username),
59 ) TYPE=MyISAM AUTO_INCREMENT=5000;
62 INSERT INTO users (username,gecos,homedir,password)
63 VALUES ('cinergi', 'Ben Goodwin', '/home/cinergi', ENCRYPT('cinergi'));
64 INSERT INTO groups (name)
66 INSERT INTO grouplist (gid,username)
67 VALUES (5000,'cinergi');
70 GRANT USAGE ON *.* TO `nss-root`@`localhost` IDENTIFIED BY 'rootpass';
71 GRANT USAGE ON *.* TO `nss-user`@`localhost` IDENTIFIED BY 'userpass';
73 GRANT Select (`username`, `uid`, `gid`, `gecos`, `homedir`, `shell`, `password`,
74 `lstchg`, `min`, `max`, `warn`, `inact`, `expire`, `flag`)
76 TO 'nss-root'@'localhost';
77 GRANT Select (`name`, `password`, `gid`)
79 TO 'nss-root'@'localhost';
81 GRANT Select (`username`, `uid`, `gid`, `gecos`, `homedir`, `shell`)
83 TO 'nss-user'@'localhost';
84 GRANT Select (`name`, `password`, `gid`)
86 TO 'nss-user'@'localhost';
88 GRANT Select (`username`, `gid`)
90 TO 'nss-user'@'localhost';
91 GRANT Select (`username`, `gid`)
93 TO 'nss-root'@'localhost';