‫Okay.
‫So now I'm going to show you how to create a new user through MySQL workbench.
‫I'm also going to show you how to create a new user through through the shell, and how to give permissions
‫to that user for specific databases.
‫So we'll start with workbench.
‫If you go to the administration tab there's this users and privileges.
‫You can click on that.
‫And then you can click Add Account.
‫And you can call this user whatever you want.
‫I'm going to call mine Brad.
‫And then you can give it a password.
‫Okay, it does say weak password, but I believe it will allow me to to use that.
‫So you also have account limits.
‫Like you can set the max number of queries and updates connections.
‫We're not going to do any of that for administrative roles.
‫I'm going to check DBA which is going to grant all rights to this user.
‫So this is basically like a super user schema privileges.
‫So for this I don't believe we have to add anything new here.
‫Let's see.
‫Add entry.
‫Yeah.
‫We'll say all schemas.
‫Let's do that.
‫All schemas and.
‫Check all of this.
‫Although since we chose diva, don't believe we have to do this, but I'll usually do this anyways.
‫So let's click apply.
‫All right.
‫And then.
‫Yeah, that should have created the user.
‫So you can see over here now we have user Brad.
‫And the percent just means any host.
‫You can change that to local host if you want.
‫Actually let's do that.
‫We'll just say local host.
‫And apply.
‫All right.
‫So now we have that user and it's basically a super user.
‫We can use it when we create our application.
‫You can connect using that that user.
‫Now let's go to the shell.
‫So I'll open up my terminal.
‫And what I'm going to do is log in as the user I just created.
‫Excuse me so we can say dash u.
‫And then Brad instead of root or whatever you called your, your user and then Dash P and then it will
‫ask for the password okay.
‫And now we're logged in.
‫Now I do have on that gist that cheat sheet.
‫So this right here I have the all the all the commands to or I should say the queries to create a user
‫and grant privileges.
‫ET cetera.
‫So we can also see all the users by doing select let's say select user and host host from.
‫MySQL dot user.
‫And there we go.
‫So you can see we have the root user and the Brad user.
‫And then some system stuff that we're not going to mess with.
‫All right.
‫Now to create a new user we can say create.
‫User and then whatever we want to call and you can see right here now in this it says at local host
‫you can do that if you want.
‫Yeah.
‫Let's we'll just do that.
‫So in quotes here we want to say whatever you want to call this I'm going to say Brad too.
‫And then outside of the quotes we can say at and then some quotes with local host and then we can say
‫identified by and then we can put our password.
‫So we'll just put in one through six semicolon and there we go.
‫So now if I run that select again you can see I have a user of Brad two.
‫Now that user doesn't have privileges at the moment.
‫Right.
‫So what I want to do is basically add the same privileges that I did with the original Brad user.
‫So we can say grant, grant all privileges.
‫So we want to say on and I want to basically grant to all tables.
‫So we can do asterisk and then dot asterisk.
‫And then to the user that we want which is going to be Brad two.
‫And if we look up here.
‫We want to do at local host as well.
‫Make sure you put the At outside of the quotes, and then you have another set of quotes with local
‫host.
‫All right.
‫So let's run that.
‫We get query okay.
‫Good.
‫Now you can show the grants for a user as well.
‫So we'll say show grants for and let's do Brad the regular Brad user first.
‫Uh oh.
‫Let's do.
‫A local host.
‫Okay, so if we look up here, these are all the grants.
‫So select insert update, just basically everything and let's show the grants for Brad to.
‫So pretty much, you know, same thing.
‫And if you want to revoke or remove grants, you can do this.
‫Revoke all privileges so you can do it like that.
‫If you want to delete a user, you can say drop user and then whatever the user name.
‫So pretty easy right?
‫I just did we did the same thing here that we did within workbench just within the command line.
‫So now we have a user that we can work with.
‫I'm just going to exit out of the shell.
‫And in the next video we're going to start.
‫We're going to get jump back into some code.
‫And we're going to get started with PDO and connecting to our database.