- 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.
- CREATE TABLE IF NOT EXISTS `country` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(255) NOT NULL, PRIMARY KEY (`id`) )
- Its time to add some values in country Table. clcik on SQL Tab and write following INSERT Query to add some countries.
- INSERT INTO `country` (`name`) VALUES ( 'Afghanistan'), ( 'Africa'), ( 'Albania'), ( 'Algeria'), ( 'Andorra'), ( 'Canada');
- For View click on SQL Tab and Write Below Query.
- SELECT * FROM `country`
- For Update click SQL Tab and write below Query.
- UPDATE `country` SET `name` = 'Australia' WHERE `name` = 'Afghanistan';
- Now if you want to grant this database access to someone else you have to write below SQL Query in SQL Box.
- CREATE USER 'username'@'%' IDENTIFIED BY 'passwordforuser'
- To Grant SELECT option to specific user write below code
- GRANT SELECT ON search.country TO 'username'@'%'
- To Grant UPDATE option to specific user write below code
- GRANT UPDATE ON search.country TO 'username'@'%'
- To Grant INSERT option to specific user write below code
- GRANT INSERT ON search.country TO 'username'@'%'
- You can check Grant option for any user by writing below code.
- SHOW GRANTS FOR 'username'@'%';
Website Link for this tutorial is Crewow website
No comments:
Post a Comment