Starting MySQL

From SQLZOO
Jump to navigation Jump to search

Running MySQL

Name of the server mysqld or mysqld.exe
Name of the client mysql or mysql.exe
Typical command line to start the client c:\mysql\bin\mysql -h pc236nt.napier.ac.uk -u scott -p gisq

pc236nt.napier.ac.uk

the internet address of a computer running the server

scott

the user name

gisq

the name of the database to use

-p

forces a prompt for password

Useful commands
show tables;
describe tableX;
use databaseY;
help
source file.txt
Beware! Foreign keys are not enforced. Table names are case sensitive when running on Unix

The MySQL client is called mysql.

C:\>c:\mysql\bin\mysql -h pc236nt.napier.ac.uk -u scott -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 33601 to server version: 3.23.43-log

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

use gisq
Database changed
mysql>SELECT name FROM cia;
...
| Western Sahara                               |
| Yemen                                        |
| Zambia                                       |
| Zimbabwe                                     |
+----------------------------------------------+
261 rows in set (0.01 sec)
mysql>exit

Some useful commands in MySQL:

  • show tables;
  • describe cia;