Join Sheeri Cabral for an in-depth discussion in this video Easy ways to play with MySQL, part of Learning MySQL Development.
For this course you will need access to a running instance of MySQL. It would be best if you had access on your local machine. Throughout this course I will be using the MySQL command line, which looks like this. This is where we can type in commands on the MySQL command line. If I wanted to type the command SHOW DATABASES, this is what it would look like. And this is how we can get information from MySQL on the command line. We will be showing all examples with MySQL 5.6, which will work on MySQL and Percona server versions 5.1 and up, and all MariaDB versions.
If you're more comfortable with a graphical user interface, there is a free GUI tool for MySQL called MySQL Workbench. You can download it from MySQL.com, under MySQL Workbench & Utilities. Once you have downloaded and installed MySQL Workbench, you can setup a connection to an existing database. Click the plus sign to add a connection, and then enter in the relevant details. Test the connection. If everything works out, click OK to save the connection. You can then click the connection to open an SQL editor where you can then type in commands.
Click on a lightning bolt to run the command, and you can see the output is shown at the bottom here. Here's the output And here's a little information about how long it took, and the response. There were four rows returned. If you do not have MySQL running on your local server, or just want to access a MySQL database via the internet, then you can go to sqlfiddle.com. You can choose what database you want to use, at the top. You can even choose to use an online SQL database if you want. The first thing that you should do is build the schema.
See here, it says Please build schema. So you click the Build Schema button. Once the schema is built, you can type commands into the window on the right. And then click the 'Run SQL' button or press Ctrl+enter to actually run the statement you just wrote. You can also choose what your output will look like right here. So you can have Plaintext Output, Tabular Output or Marked down Output and all the output is down here at the bottom. There's also a tool called phpMyAdmin, which is a standalone graphical tool where you can connect to an existing MySQL Server via a web browser.
You can install phpMyAdmin on a machine with a web server, or you can use their demo site at phpmyadmin.net. Click the try demo button on the website. Once you are on the demo server, click the SQL tab at the top to get to a SQL editor. This is where you can type your commands in and get your answers. Type in this window then click the go button to get all of the databases here. So now you know of several different ways to work with MySQL.
- Exploring MySQL data types
- Creating a database
- Creating tables
- Reading and adding data
- Using date and number functions
- Sorting results
- Inserting and replacing records
- Joining tables