Difference between revisions of "MySQL basics"
Line 23: | Line 23: | ||
Install the client programs | Install the client programs | ||
== Basic Commands == | |||
Virtually all commands are terminated with a semicolon. | |||
The prompt '->' means MySQL is waiting for more instructions or the semicolon is missing.<br> | |||
Cancel current command <code>\c</code> and press Enter.<br> | |||
MySQL will ignore anything in a command that ends with <code>\c</code> and go back to beginning. | |||
Type <code>exit</code> or <code>quit</code> and press Enter anytime you want to exit. These commands do not require a semicolon. | |||
<code>show databases;</code> | |||
<code>drop database <db_name>;</code> | |||
<code>create database <db_name>;</code> | |||
<code>use <db_name>;</code> |
Revision as of 18:27, 15 July 2007
Getting Started with MySQL
Connecting to MySQL
To access a MySQL db you need:
- user name and password
- host name or IP
- name of db
Two ways to access MySQL directl
- command line:
- telnet
- SSH (recommended due to enhanced security)
- MySQL client programs [
mysql, mysqladmin, mysqldump
]
To access a database from the command line
mysql -u username -ppassword -h hostname databasename
Note: There is no space between the -p and the password. Password after -p is optional here. If left blank, you will be prompted to enter your password.
Using MySQL Client Programs
Install the client programs
Basic Commands
Virtually all commands are terminated with a semicolon.
The prompt '->' means MySQL is waiting for more instructions or the semicolon is missing.
Cancel current command \c
and press Enter.
MySQL will ignore anything in a command that ends with \c
and go back to beginning.
Type exit
or quit
and press Enter anytime you want to exit. These commands do not require a semicolon.
show databases;
drop database <db_name>;
create database <db_name>;
use <db_name>;