Hello and welcome back, this is Video #3, and we’re going to talk about How to Create a MySQL Database. And then we will talk about in addition to that How to Insert Data Into a MySQL Database, how to look at the database and how to understand the basics of it, so that if you ever need to do this in the future, you can.
So when it comes to installing a MySQL database, it’s actually very, very easy thing to do. It’s simply click, click, in a few clicks and you’re done. And I’ll show you exactly the step by step process of doing that. However, with that said, how do you go about inserting data into the database if you ever need to do that? Well this is often underutilized, but needed in the long term wherever you’re running your website. So with that said, let me go ahead and show you how.
So to create a MySQL database it’s super easy, let’s start at the top. So make sure that you are logged into your cPanel and what you want to do is scroll downwards and look for databases. If it’s different than – basically what you want to do is look for the MySQL Database Wizard, and this will walk you through, step by step, it’s the easiest way to go. So first things first, click on this, and then it’s going to ask you what you want to name your database. Now this right here is going to be your domain name, so it’s going to be different for different people, and you don’t have to worry about that. So just enter a database name, so we will say DB and this could be anything you want, you just need to remember what it is. Click on Next Step, and then you want to create a username. So the username or the user has access to the database, so this is separate. So you are creating a username and then you are creating a separate database so that user has access to that user. So let’s put that in here, we will just say user1, and then of course you want to do a password. And what I usually like to do is click on Password Generator, because then you choose a very complex password. So you can click Generate Password here. I’m going to pause this video right now and create a random password and we’ll copy it down here.
So once you are done with that you just click on the checkbox that says I’ve copied this into a safe place and I am ready to use the password and then it automatically enters it here. So as you can see it is a very strong password and we click Create User.
The next step, step 3 is to add the user to the database and to do that all you have to do is click on All Privileges and click Next Step. And that’s it. So now what you need to do is hopefully you have saved the password to a very safe place, usually what I do is I open up a notepad and then I save it here. Now in addition to that I usually try to save this right here, so if you are installing a web script, typically what it will do is it will ask you for your database name, and the database name is the full text between these quotation marks. So I’m going to copy that over here, so that’s the database name. So I usually do DB=this and then the user = this, and keep that in a safe place. So as u can see that’s how easy it is to create a MySQL database.
Now what I want to do is click on return to MySQL databases and if we scroll down we can see that the database has been created. Now if I go back to the outside here, and I’m going to click on the logo, and that just brings me back to the home page, I’m going to go back down and look for phpMyAdmin. What this allows you to do is to take a peek at the database itself. Now I’ll warn you and I’ll will say that do this very, very cautiously, because any mess up you could potentially mess up your whole site. But I wanted to show you this because sometimes if you have basic detective skill you will be able to kind of get an idea of what’s going on inside the database. So if you click on phpMyAdmin it will open up and it will allow us to edit specific databases. Now obviously you want to find the database that you just named, so in this case it was the DB base, so it’s this one right here. We can click on here. So we can see that there are no tables found and the reason why – it’s an empty database, right. But let’s say for example that we choose a different database that has data inside of it. So what I’ve done is I’ve gone into a WordPress site database. In this case, I’m not going to show you the username or password and all of that, but I want to show you some of the basics. So whenever you install a WordPress site for example it will have installed plugins and all of that, and sometimes you will see plugin database tables inside of here. So sometimes you can actually edit the data that is inside of these tables. But if you are just curious, just come in and take a look and see what happens, and see inside of it. Now obviously I’d be very, very careful if you are editing a site that you really care about. But by doing this and just looking at it, not really changing anything, this really gives you an idea of what is happening on the back end of your website. And the reason why I’m showing this to you is because in the past I used to do this and whenever I came across an error or maybe there was something on the site that I couldn’t change on the front end, sometimes I would go in the back end, like right here, let’s say wp_comments for example. You could see comments and all of that here. So what I’m showing you this is the – you can actually replace existing data with data that you want. And just coming through here and being able to see what’s happening on the back end, really allows you to see what is really happening in your site.
Now this is very useful just in case you get locked out, especially if you get locked out of your website and you have to change your username and password, but it just won’t let you in. So what you could easily do is that you could come down here and go under wp_users and then just change the password inside here. So that’s why I’m showing you this, it’s because there are potential opportunities in the future if something bad happens, and you could potentially come in and get things fixed. But obviously if you don’t know what you are doing, then you will need to consult someone that does. But hopefully that gives you a better understanding on how MySQL databases work when you create them and when they begin to populate, everything happens right here.