Skip to Content
MySQL in a Nutshell
book

MySQL in a Nutshell

by Russell J. T. Dyer
May 2005
Intermediate to advanced
352 pages
14h 39m
English
O'Reilly Media, Inc.
Content preview from MySQL in a Nutshell

Name

mysql

Synopsis

mysql options [database]

You can use the mysql client to interface with MySQL in terminal or console mode. To enter terminal mode, you would enter something like the following from the command line:

mysql -u russell -p

After entering this, if the MySQL server is running the user will be prompted for a password. Once in terminal mode, SQL statements may be entered to view or to change data.

As an alternative to terminal mode, when performing straightforward tasks in MySQL one can still use the mysql client from the command line. For instance, to execute a batch file that contains several SQL statements that will insert data into a database, you could do something like this:

mysql -u russell -ppassword db1 < stuff.sql

In this example, the password is given so that the user isn't prompted. It's entered immediately after the -p option, without a space in between. Next the database name db1 is given. The redirect (the less-than sign) tells the shell to input the text file stuff.sql to the command. When the client has finished processing the text file, the user is returned to the command prompt.

Several options may be given when calling the mysql client. They are listed alphabetically here:

--auto-rehash

Generates a hash of table and column names to complete the names for users when typing in terminal mode by pressing the Tab key after having entered the first few letters of the name.

--batch, -B

This default option displays data selected with fields separated by tabs and rows ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

MySQL Cookbook

MySQL Cookbook

Paul DuBois
MySQL 8 Cookbook

MySQL 8 Cookbook

Karthik Appigatla
MySQL Reference Manual

MySQL Reference Manual

Michael Widenius, David Axmark, Kaj Arno
MySQL Stored Procedure Programming

MySQL Stored Procedure Programming

Guy Harrison, Steven Feuerstein

Publisher Resources

ISBN: 0596007892Errata Page