1CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';
2GRANT ALL PRIVILEGES ON * . * TO 'newuser'@'localhost';
3FLUSH PRIVILEGES;
1create database [DB name];
2
3CREATE USER '[DB_User_Name]'@'localhost' IDENTIFIED BY '[DB_Password]';
4GRANT ALL PRIVILEGES ON [DB_Name].* TO '[DB_User_Name]'@'localhost';
5
6show grants for 'demouser'@'localhost';
7
8FLUSH PRIVILEGES;
1-- Grants list
2SELECT * FROM information_schema.user_privileges;
3SELECT CONCAT('SHOW GRANTS FOR ''',user,'''@''',host,''';') FROM mysql.user;
4
5-- Grant a user
6/* ALL PRIVILEGES All privileges
7 CREATE Create databases and tables
8 DROP Drop databases and tables
9 DELETE Delete rows from a specific table
10 INSERT Insert rows into a specific table
11 SELECT Read a database
12 UPDATE Update table rows */
13GRANT SELECT, UPDATE ON db_name.table_name TO 'my_user'@'localhost';
14GRANT SELECT ON *.* TO 'my_user'@'localhost';
15GRANT ALL PRIVILEGES ON db_name.* TO 'my_user'@'localhost';
16
17--Display user grants
18SHOW GRANTS FOR 'my_user'@'localhost';
1/*
2The GRANT statement is used to assign full control over specific database by providing all priviledge.
3Follow below statement for assign priviledge to user
4*/
5
6Syntax:
7GRANT ALL PRIVILEGES ON database_name.* TO 'username'@'localhost';
8
1if(curl_exec($ch) === false)
2{
3 echo 'Curl error: ' . curl_error($ch);
4}
5else
6{
7 echo 'Operation completed without any errors';