If you are using Sequel Pro, go to the “Query” tab. If you are using the command line, make sure you are in the mysql command line, and remember to end your statements with semicolons.
From this point on, I’m assuming that you have access to a MySQL database and that your username and password have been set up to let you work on that database.
- Working with data: Connect
- If you are not connected to your MySQL server, connect to your server the same way you did earlier.
- Change password
- It is a good idea to change your password regularly. Usually, your initial password is sent to you by way of e-mail. E-mail is notoriously insecure, so it is always a good idea to change your password as soon as you connect the first time.
- Choose database
- In Sequel Pro, you’ll choose your database from the pull-down menu in the upper left. On the command line, you’ll choose your database by typing “use databasename;” and pressing the return key on your keyboard.
- About Tables and Columns
- All of your data in MySQL is stored in tables. When you view tables, they look a lot like spreadsheets. Each table consists of rows and columns. A row is one record; it is one set of data. A column is a field: it is one piece of data that each record has.
- Create a table
- We’re going to keep track of albums and tracks. We’ll create the albums table first. Before creating a table, it is a good idea to think of what you will need in that table. For our albums table, we will want:
- Import data
- We have two sets of sample data. The one we’re looking at right now is the albums.txt file. This file is a tab-delimited list of albums, artists, years, and date purchased.
- Working with data: View data
- You can use Sequel Pro’s pull-down menu to look at the data, but this is a lot like the simple view in Dreamweaver. If you need to do anything special, you will need to understand the select command.
- Backup Data
- You must backup your data regularly. You should perform a backup as often as you change data. In Sequel Pro, this is performed from the Export menu item under the File menu. On the command line, you can do the same with: