Difference between revisions of "ComMySQL"

From SQLZOO
Jump to navigation Jump to search
(Created page with "<h1>Running MySQL</h1> <table border="1"> <tr> <th>Name of the server</th> <td>mysqld or mysqld.exe</td> </tr> <tr> <th>Name of the client</th> <td>mysql or mysql.exe</td> </...")
 
 
Line 20: Line 20:
 
  <dd><p>the user name</p>
 
  <dd><p>the user name</p>
 
<dt><p>gisq</p>
 
<dt><p>gisq</p>
  <dd><p>the name of the database to use
+
  <dd><p>the name of the database to use</p>
 
<dt><p>-p</p>
 
<dt><p>-p</p>
 
  <dd><p>forces a prompt for password</p>
 
  <dd><p>forces a prompt for password</p>
Line 48: Line 48:
 
</p>
 
</p>
 
<pre style="padding:1em;color:black; background-color:rgb(192,192,192);width:100ex;">
 
<pre style="padding:1em;color:black; background-color:rgb(192,192,192);width:100ex;">
<p>C:\&gt;</span>c:\mysql\bin\mysql -h pc236nt.napier.ac.uk -u scott -p</p>
+
C:\&gt;c:\mysql\bin\mysql -h pc236nt.napier.ac.uk -u scott -p
<p>Enter password:</p>
+
Enter password:
<p>Welcome to the MySQL monitor.  Commands end with ; or \g.</p>
+
Welcome to the MySQL monitor.  Commands end with ; or \g.
<p>Your MySQL connection id is 33601 to server version: 3.23.43-log</p>
+
Your MySQL connection id is 33601 to server version: 3.23.43-log
  
<p>Type 'help;' or '\h' for help. Type '\c' to clear the buffer.<p>
+
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
  
<p>use gisq</p>
+
use gisq
<p>Database changed<p>
+
Database changed
<p>mysql&gt;</span>SELECT name FROM cia;</p>
+
mysql&gt;SELECT name FROM cia;
<p>...
+
...
 
| Western Sahara                              |
 
| Western Sahara                              |
 
| Yemen                                        |
 
| Yemen                                        |
Line 65: Line 65:
 
+----------------------------------------------+
 
+----------------------------------------------+
 
261 rows in set (0.01 sec)
 
261 rows in set (0.01 sec)
</p>
 
 
mysql>exit</pre>
 
mysql>exit</pre>
 
<p>Some useful commands in MySQL:</p>
 
<p>Some useful commands in MySQL:</p>

Latest revision as of 10:24, 19 July 2012

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;