MySQL for the Internet of Things

(Steven Felgate) #1

Chapter 5 ■ MySQL priMer


What IS OpeN SOUrCe? IS It reaLLY Free?


Open source software grew from a conscious resistance to the corporate-property mind-set. While
working for Mit, richard Stallman, the father of the free software movement, resisted the trend of
making software private (closed) and left Mit to start the GNU (GNU Not Unix) project and the Free
Software Foundation (FSF).

Stallman’s goal was to reestablish a cooperating community of developers. he had the foresight, however,
to realize that the system needed a copyright license that guaranteed certain freedoms. (Some have called
Stallman’s take on copyright “copyleft,” because it guarantees freedom rather than restricts it.) to solve this,
Stallman created the GNU public License (GpL). the GpL, a clever work of legal permissions that permits the
code to be copied and modified without restriction, states that derivative works (the modified copies) must
be distributed under the same license as the original version without any additional restrictions.

there was one problem with the free software movement. the term free was intended to guarantee
freedom to use, modify, and distribute; it was not intended to mean “no cost” or “free to a good home.”
to counter this misconception, the Open Source initiative (OSi) formed and later adopted and promoted
the phrase open source to describe the freedoms guaranteed by the GpL license. For more information
about open source software, visit http://www.opensource.org.

How Do I Use MySQL?


MySQL runs as a background process (or as a foreground process if you launch it from the command line)
on your system. Like most database systems, MySQL supports Structured Query Language (SQL). You can
use SQL to create databases and objects (using data definition language [DDL]), write or change data
(using data manipulation language [DML]), and execute various commands for managing the server.
To issue these commands, you must first connect to the database server. MySQL provides a client
application named mysql^3 that enables you to connect to and run commands on the server. The client
accepts SQL commands as well as a few commands specific to the client itself. A semicolon must terminate
all commands.


■Tip to see a list of the commands available in the client, type help and press enter at the prompt.


To connect to the server, you must specify a user account and the server to which you want to connect.
If you are connecting to a server on the same machine, you can omit the server information (host and port)
as these default to localhost on port 3306. The user is specified using the --user (or -u) option. You can
specify the password for the user on the command, but the more secure practice is to specify --password
(or -p), and the client with prompt you for the password. If you do specify the password on the command
line, you will be prompted with a warning encouraging you to not use that practice.
Using the mysql client on the same machine without the --host (or -h) and --port option does not
use a network connection. If you want to connect using a network connection or want to connect using a
different port, you must use the loopback address. For example, to connect to a server running on port 13001
on the same machine, use the command mysql -uroot -p –h127.0.0.1 --port=13001.


(^3) Sometimes called the MySQL monitor, terminal monitor, or even the MySQL command window.

Free download pdf