In this tutorial we will be looking at phpmyadmin – the best way to manage your mysql databases as far as I’m concerned, especially for those who are just starting out. We shall start out with a little bit on what mysql is, what phpmyadmin is, and how they are tied together. We shall first look at starting up phpmyadmin, and how to setup users and change passwords. We will then be ready for future tutorials on how to set up a database and use the menu system to manage our data. Exciting stuff! Before we get started, it’s important that you have a flavour of the Apache, Mysql, PHP development stack installed. If you haven’t, I detail how to do this for windows in this post where we install XAMPP
Now – disclosure time – I have never spent the time learning about databases, the different types, and their uses, that I have put into learning code. I have developed mereley a working knowledge of mysql – ie. all that I needed to know to make applications work. Over time I have learned a few tricks and begun to understand the best way to put a database together using the various tools that I will be describing in this tutorial. If you want an in-depth understanding as to what a database is, how the different models work, the inner workings of a database, or anything that goes deeper than merely knowing how ‘to make it happen’, then I encourage you to turn to our good friend Google. If you just want to know how to use a database with your websites and applications, then keep reading :)
What is mysql?
Mysql is a database – the most popular open source database available today. A database is merely an ordered and structured way of storing information, so that it is easy to query and retrieve data. There are many different types of databases, each with their own methods of use, syntax, strengths and weaknesses. Mysql is what is know as a Relational Database. What this means isn’t too important at first if all you want to happen is to store and retrieve information in your own applications. You only need to know that mysql is the most popular database for good reason; it is quick and easy to install, easy to get a working understanding in a short space of time, and has a massive user base to help you with any problems you may encounter. In my opinion, it is most defiantly the best database for beginners.
What is phpmyadmin, do I have it, and how do I start it?
We need a way to access our database – to add information and retrieve this information. One way is to use the terminal, or command line – ie. type in all the commands. If you are not familiar with using a terminal already, this can seem daunting, and many people are much more comfortable with using a graphical interface. One very popular interface is phpmyadmin – its popularity in no small part due to its ease of use, great user base, and being part of the XAMPP distribution. Phpmyadmin allows us to see a table-like representation of our database, gives us easy to use menus to perform common tasks, and is an all round good-egg.
Having followed this tutorial, you will have mysql and phpmyadmin installed on your computer. To start phpmyadmin is easy. Make sure apache server and mysql is running and then point your browser to:
You will be asked for a username and password. If you have not specified any password during the install of XAMPP or since, then you only need to supply a username of ‘root’. After logging in, you should see the phpmyadmin panel.
First Things First – Security
I’m sure if you stop to think about it, having a username of root with no password isn’t very secure. So the first thing to do, before we get carried away with making databases, is to change our login credentials. Let’s do that now.
In the top menu bar you will see the option – ‘Privileges’. Click on this.
You will then be brought to the privileges page, surprise! You will see a list of current users, forgive me, but I forget what you get on a vanilla install as it’s be so long since I had one. As you can see from my screenshot below I have a load of different users (blurred out) from all my different projects. You want to click the option at the bottom, ‘Add a new User’.
You will then be given a pop-up window:
Enter a username, then in the next row, you can use the dropdown menu to select ‘local’. Then enter a password and confirm it. Scroll the window down to a section that says ‘Global privileges( Check All / Uncheck All )’. Click on ‘Check all’. You can now click ‘Create User’ at the bottom of the window. You should then see a success message, and your new user in the list of users. Now remember your username and password! You will be using them not only to login to phpmyadmin, bust also to allow any future php applications access to your database.
What to do with Root?
So we have our new user, but we’re still not done with security. Remember that root user without a password? We don’t want to leave that user hanging around. Find the root user in the list of users, and looking along the row, find and click the Edit Privileges link. In the pop-up window that opens, srcroll down to the ‘Change Password’ section and click the ‘Password’ radio button. Put in a password that you can remember and re-type. Click ‘Go’, and there you have it. We’re done.
Now we have set up our phpmyadmin with a user and secured out root user, we can go on to the real business of building a database. In the next tutorial we will do just that by getting familiar with the phpmyadmin dashboard and the menu system. So see you then!
If you would like to be kept up to date with new posts here at the web developing cat, then be sure to add your name to our mailing list below.