Database Reference
In-Depth Information
Protecting option files from other users
On a multiple-user operating system such as Unix, protect the option file located in
your home directory to prevent other users from reading it and finding out how to
connect to MySQL using your account. Use chmod to make the file private by setting
its mode to enable access only by yourself. Either of the following commands do this:
% chmod 600 .my.cnf
% chmod go-rwx .my.cnf
On Windows, you can use Windows Explorer to set file permissions.
1.5. Executing SQL Statements Interactively
Problem
You've started mysql . Now you want to send SQL statements to the MySQL server to be
executed.
Solution
Just type them in, letting mysql know where each one ends. Or specify “one-liners”
directly on the command line.
Discussion
When you invoke mysql , it displays a mysql> prompt to tell you that it's ready for input.
To execute an SQL statement at the mysql> prompt, type it in, add a semicolon ( ; ) at
the end to signify the end of the statement, and press Enter. An explicit statement ter‐
minator is necessary; mysql doesn't interpret Enter as a terminator because you can enter
a statement using multiple input lines. The semicolon is the most common terminator,
but you can also use \g (“go”) as a synonym for the semicolon. Thus, the following
examples are equivalent ways of issuing the same statement, even though they are en‐
tered differently and terminated differently:
mysql> SELECT NOW();
+---------------------+
| NOW() |
+---------------------+
| 2014-04-06 17:43:52 |
+---------------------+
mysql> SELECT
-> NOW()\g
+---------------------+
| NOW() |
+---------------------+
| 2014-04-06 17:43:57 |
+---------------------+
Search WWH ::




Custom Search