Start learning with our library of video tutorials taught by experts. Get started
Viewers: in countries Watching now:
PHP is a popular, reliable programming language at the foundation of many smart, data-driven websites. This comprehensive course from Kevin Skoglund helps developers learn the basics of PHP (including variables, logical expressions, loops, and functions), understand how to connect PHP to a MySQL database, and gain experience developing a complete web application with site navigation, form validation, and a password-protected admin area. Kevin also covers the basic CRUD routines for updating a database, debugging techniques, and usable user interfaces. Along the way, he provides practical advice, offers examples of best practices, and demonstrates refactoring techniques to improve existing code.
In this video, we're going to do some configuration to MySQL. Specifically, I want us to set a root password, MySQL, because by default, MySQL comes with no default password for the root user. Root user being the most powerful user on the system. The one with the most privileges inside MySQL. And it's just a good security practice to always have a default password set, so that only someone who knows that password can get access to the data that's in the database. Now you may think, well, I'm not going to be sharing this data with anyone.
It's only on my personal laptop. I'm the only one who uses it. But it is a good practice, because you may end up importing some data from a production database, at some point, onto your development machine. And if someone were to come and find your laptop, or if you were to lose it, they could get access to all of the data that was on there. So I want us to go ahead and follow this best practice and set a root password for MySQL. Now the tool that we need in order to update the MySQL password is MySQL Admin, the tool that's installed with MySQL. WAMP gives you lots of nice tools here from this directory, but they don't give you one for MySQL Admin.
They do give you a way to go directly into MySQL here, MySQL console. That's kind of nice. Comes up and says enter password, and since there is no password right now, I can just hit Return and it puts me directly into MySQL. So I've logged in as the root user. I didn't have to type a password. I just simply hit Return. Now I'm in MySQL. Instead, I like to be able to enter a password. Now to do that, we're going to have to go to the console. The Command Prompt. So you want to find the Command Prompt that's going to be inside all of your programs, inside Windows System.
Command Prompt, you'll find it there. This is the command line interface to Windows. Don't be intimidated by it, we're not going to be here for very long. What we want to do, is we want to navigate to the place where MySQL Admin lives. If we just type mysqladmin on its own, it comes up and says sorry, I don't know what that is. But if we go to cd, change directory, C, that's a capital C:\wamp\bin\mysql. And then we type dir, we'll get a listing here, and this folder name will change depending on what version of MySQL you have.
Now we want to do another cd mysql, and you can actually just hit the Tab and it should auto-complete for you. If not, go ahead and type that full number out there, and that will change directories one more time and then put /bin after it. So now we're inside a place where all of the programs live for MySQL. We could actually click the dir, we can see what all those are. The one that we want is MySQL Admin. Then after it put dash u space root for the root user, and then we want to type password because that's what we want to change.
So all lower case password. We'll hit Return, and it will then come up and ask us for the new password that we want to set. So I'm going to set mine just to be secret for now, secret and it doesn't show it. It just has the bullets there instead, hit Return, confirm it, and I'll type it again, and now it's set. That's my new password that I have to type to get in. When I hit the Up arrow, and it will bring that line back up again. If we want to change it again to something different, it'll come up and it'll say oops, sorry, I needed some kind of indication that you wanted to give a password. So what we need to do is actually just go back and make a small edit to this line and put dash p, which means I will be providing a password. So it will ask me for the password, it's going to prompt me for it. But I'm just letting it know, look, it's not okay to just go with no password and then when it says enter password here.
It wants my old password, which is secret. And now it wants the new password. But I'm going to change it. I'm going to make my password johnpaulgeorgeringo. And then it will ask me to confirm it. johnpaulgeorgeringo. And now it's set. So now that's my new password for my root user. And we can confirm that by coming back over here and going into MySQL to the console.
And if we just type return this time, it says nope, sorry, no good and it closes on us. If we try it again, MySQL console. And this time I type johnpaulgeorgeringo, there I am, now I'm inside My SQL and just typing exit will get us out of there. Now there is one other thing that I want to mention to you about this. Which is that with WAMP is also included an application allied PHP My Admin. It's a very popular way to look at your MySQL databases and to manage them by using a PHP web interface. Now we're not going to be using that as training, we're going to be using MySQL directly, using the MySQL console.
But I just want to mention that we did just break phpMyAdmin because it's not setup to use a password. If you want it to use a password, you need to go back to your command prompt, navigating to C:\wamp. And then in there if you look, you'll see there's a directory called Apps so we will also change directory into Apps. And then inside here is PHP MyAdmin with a version number after it. So we'll just use Tab to auto complete that for us. And then inside here, you'll find that there's a file all the way at the top called config.inc.php and that is where it gets its configuration. So you would edit this file and you would find the location where it has password and change that to be your new root password.
So I just wanted to mention that to you. Even though we won't be using it in this training, I didn't want to leave you with some software that we broke without giving you some direction on how to fix it.
Find answers to the most frequently asked questions about PHP with MySQL Essential Training.
Here are the FAQs that matched your search "":
Sorry, there are no matches for your search ""—to search again, type in another word or phrase and click search.
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.