Wednesday, February 26, 2020

User creation on MySQL and giving Privileges


mysql> CREATE USER 'good'@'localhost' IDENTIFIED BY 'man';
Query OK, 0 rows affected (0.16 sec)

mysql> GRANT ALL ON iot.* TO 'good'@'localhost';
Query OK, 0 rows affected (0.18 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.12 sec)
-------------------------------------------------------------------------------------------------------------------------

Here localhost means that  Data Pushing Application and MySQL DB Server both are on the same System.
--------------------------------------------------------------------------------------------------------------------------
If Data Pushing Application  and MySQL DB Server are on different Systems.

Then we give  the permission to that  Data Pushing Application like ..
CREATE USER 'good'@’2.16.1.200’ IDENTIFIED BY 'man';
GRANT ALL ON iot.* TO 'good'@'2.16.1.200';   (Here 2.16.1.200 is the Data Pushing Application IP Address.)
---------------------------------------------------------------------------------------------------------------------------------------------------------------------
If we want to access any host(IP Address of any System) then
 CREATE USER 'good'@’%’ IDENTIFIED BY 'man';
GRANT ALL ON iot.* TO 'good'@'%';   (Here % means that Any host can access our MySQL Server DB)
-------------------------------------------------------------------------------------------------------------------------

No comments:

Post a Comment

Recent Post

Databricks Delta table merge Example

here's some sample code that demonstrates a merge operation on a Delta table using PySpark:   from pyspark.sql import SparkSession # cre...