Starting and Terminating mysql
Problem
You want to start and stop the mysql program.
Solution
Invoke
mysql from your command prompt to
start it, specifying any connection parameters that may be necessary.
To leave mysql, use a
QUIT
statement.
Discussion
To start the mysql program, try just typing its
name at your command-line prompt. If mysql starts
up correctly, you’ll see a short message, followed
by a mysql> prompt that indicates the program
is ready to accept queries. To illustrate, here’s
what the welcome message looks like (to save space, I
won’t show it in any further examples):
% mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 18427 to server version: 3.23.51-log
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>If mysql tries to start but exits immediately with an “access denied” message, you’ll need to specify connection parameters. The most commonly needed parameters are the host to connect to (the host where the MySQL server runs), your MySQL username, and a password. For example:
%mysql -h localhost -p -u cbuserEnter password:cbpass
In general, I’ll show mysql commands in examples with no connection parameter options. I assume that you’ll supply any parameters that you need, either on the command line, or in an option file (Recipe 1.5) so that you don’t have to type them each time you invoke mysql.
If you don’t have a MySQL username and password, you need to obtain permission to use the MySQL server, as described ...