C hen installed the mysql service on our server, by default creates a root user can perform any action, because it has root privileges.
But when we work with a database concreo, whether for a website, blog or anything that requires access to database, it is recommended create a user that can only work with that database specifically and even we can put restrictions on creation, modification, etc.
To create a new user mysql , use the following statement: CREATE USER
user1 @ 'localhost' IDENTIFIED BY 'password1'; With this, we will have a new user called user1 password password1 . The user, by default, you have no permission, so we must give appropriate permissions for the user to work with a database. An example is:
GRANT SELECT, INSERT, UPDATE, DELETE ON blog .* TO 'user1' @ 'localhost'; here indicate that the user user1 can work on any table in the database blog and can perform actions: SELECT, INSERT, UPDATE, DELETE .
Actions allows GRANT are:
Select: Allows you to run SELECT statements.
Insert: allows to execute INSERT statements.
Update: Run UPDATE statements.
Delete: Allows you to run UPDATE statements.
References: Ability to create a constraint that refers to the table.
Alter: Ability to change a table with the ALTER TABLE.
Index: Ability to create an indexed table with the CREATE INDEX. Using this technique
get add more security to our system when working with databases.
0 comments:
Post a Comment