Query plus Grant Privileges
Furqan Aziz | 27 Aug 2013 | Tutorials
MySQL Query Tutorial is about basic queries which require in day to day work. This tutorial also show you how to create user, Grant Privileges and Show Privileges of specific user. it also show hot to connect it from PHP Page on same Network. Before reading this Tutorial you must have installed XAMPP, Apache and MySQL must be Running.
- Open your browser and go to the link PHP Myadmin
- Now Type database Name in Field "Create new database" and Press Create. (For Example Database Name is Search)
- Now Choose Database search from Drop Down Menu and click on SQL Tab on right Side.
- Write Below query in SQL Box and Press GO for creating your first MySQL Table.
Its time to add some values in country Table. clcik on SQL Tab and write following INSERT Query to add some countries.
- CREATE TABLE IF NOT EXISTS `country` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
PRIMARY KEY (`id`) )
For View click on SQL Tab and Write Below Query.
For Update click SQL Tab and write below Query.
- INSERT INTO `country` (`name`) VALUES
Now if you want to grant this database access to someone else you have to write below SQL Query in SQL Box.
- UPDATE `country` SET `name` = 'Australia' WHERE `name` = 'Afghanistan';
To Grant SELECT option to specific user write below code
- CREATE USER 'username'@'%' IDENTIFIED BY 'passwordforuser'
To Grant UPDATE option to specific user write below code
- GRANT SELECT ON search.country TO 'username'@'%'
To Grant INSERT option to specific user write below code
- GRANT UPDATE ON search.country TO 'username'@'%'
You can check Grant option for any user by writing below code.
- GRANT INSERT ON search.country TO 'username'@'%'
- SHOW GRANTS FOR 'username'@'%';
Above tutorial Reference is from MYSQL Reference Manual
. For more information please post a comment on Crewow Blog
© 2014 CreWow Network - All Rights Reserved.