‫All right guys.
‫So now we're going to take a look at MySQL workbench which is a graphical user interface that will allow
‫us to manage our database.
‫And I chose this for a few reasons.
‫One, it's cross-platform.
‫So it doesn't matter if you're on Mac windows, Linux.
‫Two it's free.
‫I know that there are a lot of other graphical user interfaces like this that cost money, and I don't
‫want to put something in the course where you have to pay for it, aside from the course itself.
‫So this is the documentation from the course.
‫You can kind of follow along with this if you want, but this is the same, same stuff we're going to
‫do in this video.
‫Now to download MySQL workbench.
‫You just want to go to the website here.
‫And let me just bring this over real quick.
‫So it's dev.mysql.com/downloads/workbench and whatever system you're on.
‫So I'm on Mac.
‫So that's the download I have.
‫And just download it install it.
‫If you're on windows it's just a typical installer.
‫If you're on Mac just you'll just drag it over to your applications folder and you should be all set
‫and you can open it up.
‫All right.
‫Now this is what the welcome page looks like.
‫And you may or may not have a default connection.
‫If you don't, just click the plus icon and just give it a name, and then this stuff should be filled
‫in for you.
‫The host name, which is your loopback address, your local host, and then the port.
‫The default port for MySQL is 3306 and then the route.
‫So I'm using the root user.
‫All right.
‫So you just want to set up that connection click okay.
‫And then you can click on that and it will open up the editor.
‫Now from here you can do a lot of different things.
‫Create tables basically all the stuff you can do within the shell plus more.
‫You can create new users and all kinds of stuff.
‫Now what I'd like to do is the same thing we did within the shell where we created the the blog database,
‫and we had a post table just to show you that we can do the same thing through through a GUI.
‫And we'll also be using this later on when we when we start our project, we'll obviously create our
‫database through here as well for the job listings.
‫Now you have a couple of tabs up here.
‫So this is the administration tab where you can see your server status and all that stuff.
‫What we want to do is click on schemas and you can kind of use the word schema and the and the word
‫database kind of interchangeably here.
‫So what we want to do is create a new schema.
‫So we can do that by.
‫Coming down here and let's say create schema.
‫And then I'm going to call this.
‫We'll just call it blog, just like we did in the when we worked within the shell.
‫And then click apply.
‫And it says Create Schema Blog.
‫So basically when you do something within the GUI, it's going to show you the actual SQL that's going
‫to be run.
‫And then you just click apply to run that, and then it'll give you a little green check mark and tell
‫you that everything went as planned.
‫So now we have a blog schema, as you can see over here.
‫So let's close this tab up and this query tab right here.
‫So you can just straight up write queries just like as if you were in the shell.
‫But I want to do things through through the GUI this time.
‫So if we look in blog we have a couple things here.
‫We have tables, views, stored procedures, functions.
‫We're not going to get into things like stored procedures, functions.
‫This is not an advanced SQL course, but what I do want to do is create a new table.
‫So let's right click and say create table.
‫And I know this is really small.
‫I can't figure out how to make it bigger.
‫So just kind of bear with me.
‫So for the name I'm going to call it posts because I want the table to be called post.
‫And then I want to create the same fields we did within the shell.
‫We had an ID, a title, a body, and a created at.
‫So for the first column or the first field, it's going to be called ID, the data type.
‫You can see we have a bunch of data types to select from.
‫We want int integer.
‫You want to make sure that the PK field is clicked.
‫That's primary key okay.
‫We want this ID to be our unique primary key not null.
‫So n n is not null.
‫And then we also want to check I which is autoincrement.
‫So that you know, if we add a post with the id of one, then the next one is two, three and so on.
‫And then the next column that we want is title.
‫And the title is going to be a varchar.
‫And whatever you have in the in the parentheses here is the max length.
‫So we'll just say 255 for that.
‫And then I'll click not null and then for the body.
‫So we'll add a body column for that I don't want to choose varchar I'm going to choose long text so
‫there's no limit on that.
‫See.
‫Where is it?
‫Long text and we can do not null for that as well.
‫Now for the createdat let's say created underscore at and we're going to choose timestamp for this.
‫So down here timestamp and we're going to remove the parentheses okay.
‫So we want to set timestamp.
‫And we're going to set a default value.
‫And we want that to be the current timestamp.
‫So under here where it says default slash expression let's say current underscore timestamp.
‫Okay.
‫And make sure that this doesn't have quotes around it, because if it does, it's going to give you
‫the default value of a string that just says current timestamp.
‫So those are all the fields that I want or all the columns I want.
‫So I'm going to come down and click apply.
‫And it's going to show me the SQL that's going to be run.
‫And this is pretty much what we typed out in the shell.
‫It's going to create a table called posts.
‫And the blog schema or blog database ID is going to be an int Autoincrement.
‫And then down here it says primary key and ID okay.
‫So when we write the query out or when we did in the last video, we put primary key up here.
‫But you can also do it this way.
‫And then the title varchar body long text created at is a timestamp with a default value of the current
‫timestamp.
‫So let's click apply.
‫We get a green x which is a good sign.
‫And there we go.
‫So now if we look under tables we now have posts and under posts.
‫You have a bunch of stuff as well.
‫But if you want to see the data that's in your post table, we can right click and say select Rows,
‫limit 1000.
‫And this would show us our data, which obviously right now we don't have any.
‫Now you can add data through this as well.
‫And there's a few ways to do that.
‫Like I said you can just you could write an Insert statement up here if you want, but you can also
‫use the form editor.
‫So from here I'll leave the ID blank because that's Autoincrement title.
‫We'll say post one and then the body.
‫This is post one and Createdat.
‫We'll leave that empty as well.
‫And then click apply.
‫It's going to again show us the actual SQL that's going to be run.
‫Click apply.
‫There we go.
‫All right.
‫Now if I wanted to add another one actually let's look at the data first.
‫So if we go back to.
‫Uh, let's see if we just say select rows.
‫There we go.
‫And you'll see ID one title post one.
‫I know this is really small text.
‫Let me see if I can.
‫Yeah, I'm not sure I know there is a way to do this, but that's search.
‫Yeah, I'm not sure how to make how to make this bigger, but we're not going to use this that much.
‫I just want to give you an introduction to workbench in this video.
‫But now we have some data.
‫So if we want to add another post we can go back to the form editor.
‫And this has our post one.
‫But if I click this little arrow right here it'll go to the next which will be empty.
‫And we can say post two.
‫I'm.
‫So post two and for the body we'll say this is post two and we'll click apply.
‫Ply again.
‫Close.
‫And now.
‫And also I just want to show you if you run this query right here.
‫So select all from blog posts and you click the lightning bolt that will run it and that will show you
‫your data.
‫So you don't actually have to keep going over and selecting select rows, you can just run this query.
‫All right.
‫And just to show you that we can.
‫Run any query we want.
‫Let's say insert into.
‫And we're going to say blog posts.
‫Actually, since we're in posts, I don't think we have to do blog.
‫So we'll say insert into posts and let's say title.
‫And body and then values.
‫Say post.
‫You want to put this in quotes.
‫So post three.
‫And let's say.
‫This is post three okay.
‫And we'll put a semicolon at the end.
‫And let's click the execute button.
‫Uh oh.
‫No database selected.
‫So I do actually have to do blog post.
‫And there we go.
‫You can see the little check mark down here.
‫So now if we select all.
‫So select all from posts.
‫Or select all from blog posts.
‫Blog posts.
‫Now you can see post three is there so you can insert data through through your custom query as well.
‫Now in the next video, I want to show you how we can add a new user.
‫If you want to use the root user without a password, that's fine.
‫You are on on your local machine, but I also want to show you how you can add a new user and set a
‫password and give that user permissions.