Beginner Series: MySQL Tutorial
Because MySQL is a web application, you would greatly benefit from working with it locally in a development environment. This will allow you to test your code as you develop content before it is published on the web.
With the way MySQL and PHP work it means that you will need to invest a bit of extra time to setup the platform locally, as opposed to what you would need to do with a traditional programming language.
Still, the work involved is negligible, considering you don’t want unfinished code live on the web for end users to deal with.
What Do You Need to Work With MySQL?
In order to begin working with MySQL you will have to install all the necessary components in the following order:
- Install Apache from the official portal
- Install PHP from the official portal
- Install MySQL Server from the official portal
- For an off the shelf local server that’s installs in a few clicks, try MAMP PRO (Mac or Windows).
- Another popular option is WAMP (Windows), which will install Apache/PHP/MySQL
If you would like to install only MySQL, following these simple instructions:
How to Get Started
After you have installed and verified each of the services mentioned in the section above, it’s time to begin working with your first database. For the purpose of this tutorial, we’re going to talk about working with the service in Windows.
To do this, you will need to open the Command Line Client from the MySQL program group that was installed on your computer. Make sure to provide it administrator access if you’re using Windows Vista or above!
When you first boot up the command prompt, it will ask you for a password. This is the password for the root account you configured when you first setup the MySQL service. Hopefully, you recorded this password for access later!
Once you’re logged in, you will see the basic interface for the MySQL environment.
The prompt should look like the following:
mysql> _
To create your first database, type the following command, and be sure to configure the options as you see fit.
CREATE DATABASE test_db;
Obviously, the “name” section is the name of the database you would like to create. It may take a moment or two for the MySQL environment to carry out the task. When it is finished you should see something like the following:
Query OK, 1 row affected (0.00 sec)
To be absolutely sure, we can use the command “Show Databases” to verify critical information related to our new database. Type “Show Databases” into the prompt and then press enter. You should see something like the following:
Database information_schema mysql test test_db 4 rows in set (0.00 sec)
Of course, this content will be displayed in a table-based configuration instead of just plain text. If this is what you see, congratulations! You have created your first database.
If you would like, you can move on to our MySQL Programming Projects for Beginners section to learn the next step, which involves creating your first table.
For the next segment of this tutorial, we’re going to cover MySQL Programming Projects for Beginners.
Disclosure of Material Connection: Some of the links in the post above are “affiliate links.” This means if you click on the link and purchase the item, I will receive an affiliate commission. Regardless, I only recommend products or services I use personally and believe will add value to my readers.