Creating a mysql user is a very common task and a very important one.

Many developers after creating a user grant them all permissions over a mysql schema and this can be a big security flaw.

When you are creating a user you must think of all permissions that user will need and grant them the correct permissions.

But let’s start creating our user:

create user hacker@'%' identified by 'Gr34tPa$$w0rd' ;

With this command we have created a user with the username ‘hacker’ and a password ‘Gr34tPa$$w0rd’

Let’s analyse each part of the command.

create user 'hacker'@'%'

Here we can choose the username that we want and after the @ sign we can choose his location. We have used the ‘%’ because we want that hack can connect this Mysql Instance from all over the world. Now if we want the user to only connect from local computer we should use:

create user 'hacker'@''

Or Only from a specific IP Address:

create user 'hacker'@''

The rest of the command is pretty easy to understand, we simple provide the password we want to assign.



This site uses Akismet to reduce spam. Learn how your comment data is processed.