databasiqs
12-17-2003, 12:42 AM
I am trying to learn the MySQL privileges system, using the code below. I had intended
to generate an error message by misspelling the password. Whether I use the right password
"johnny" or "johnnie" (wrong), the INSERT goes through -- that is not what I wanted!
Any help correcting my mistake greatly appreciated.
Many thanks in advance.
DROP TABLE IF EXISTS Orders2;
CREATE TABLE Orders2 (
account_id CHAR( 20 ), username CHAR( 20 ), password CHAR( 20 ), apples INT( 4 ),
bananas INT( 4 ), cherries INT( 4 )
) TYPE = InnoDB;
GRANT SELECT, INSERT, UPDATE
ON Orders2
TO 'john'@'localhost'
IDENTIFIED BY 'johnny';
FLUSH PRIVILEGES;
INSERT INTO Orders2 (
account_id, username, password, apples, bananas, cherries
)
VALUES (
'accountid', 'john', 'johnnie', 20, 30, 300
);
SELECT * FROM Orders2;
+------------+----------+----------+--------+---------+----------+
| account_id | username | password | apples | bananas | cherries |
+------------+----------+----------+--------+---------+----------+
| accountid | john | johnnie | 20 | 30 | 300 |
+------------+----------+----------+--------+---------+----------+
1 row in set (0.00 sec)
to generate an error message by misspelling the password. Whether I use the right password
"johnny" or "johnnie" (wrong), the INSERT goes through -- that is not what I wanted!
Any help correcting my mistake greatly appreciated.
Many thanks in advance.
DROP TABLE IF EXISTS Orders2;
CREATE TABLE Orders2 (
account_id CHAR( 20 ), username CHAR( 20 ), password CHAR( 20 ), apples INT( 4 ),
bananas INT( 4 ), cherries INT( 4 )
) TYPE = InnoDB;
GRANT SELECT, INSERT, UPDATE
ON Orders2
TO 'john'@'localhost'
IDENTIFIED BY 'johnny';
FLUSH PRIVILEGES;
INSERT INTO Orders2 (
account_id, username, password, apples, bananas, cherries
)
VALUES (
'accountid', 'john', 'johnnie', 20, 30, 300
);
SELECT * FROM Orders2;
+------------+----------+----------+--------+---------+----------+
| account_id | username | password | apples | bananas | cherries |
+------------+----------+----------+--------+---------+----------+
| accountid | john | johnnie | 20 | 30 | 300 |
+------------+----------+----------+--------+---------+----------+
1 row in set (0.00 sec)