MySQL

Aus xinux.net
Zur Navigation springen Zur Suche springen

Installation

root@asuka:~# aptitude install mysql-server mysql-client

Login

root@asuka:~# mysql --user root -h localhost -p
Enter password: XXXXXX
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 48
Server version: 5.1.41-3ubuntu12 (Ubuntu)

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 

Status überprüfen

mysql> status;

--------------
mysql  Ver 14.14 Distrib 5.1.41, for debian-linux-gnu (i486) using readline 6.1

Connection id:		48
SSL:			Not in use
Current pager:		stdout
Using outfile:		
Using delimiter:	;
Server version:		5.1.41-3ubuntu12 (Ubuntu)
Protocol version:	10
Connection:		Localhost via UNIX socket
Client characterset:	latin1
Server characterset:	latin1
UNIX socket:		/var/run/mysqld/mysqld.sock
Uptime:			41 min 4 sec

Threads: 1  Questions: 207  Slow queries: 0  Opens: 476  Flush tables: 1  Open tables: 64  Queries per second avg: 0.84
--------------

Hilfe aufrufen

mysql> help contents;
You asked for help about help category: "Contents"
For more information, type 'help <item>', where <item> is one of the following
categories:
   Account Management
   Administration
   Compound Statements
   Data Definition
   Data Manipulation
   Data Types
   Functions
   Functions and Modifiers for Use with GROUP BY
   Geographic Features
   Language Structure
   Plugins
   Table Maintenance
   Transactions
   User-Defined Functions
   Utility

Datenbanken anzeigen

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
+--------------------+
2 rows in set (0.00 sec)

Datenbank auswählen

mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A 
 
Database changed

Datenbank erstellen

mysql> create database world;
Query OK, 1 row affected (0.00 sec)
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| world              |
+--------------------+
3 rows in set (0.00 sec)

Datenbank mit Daten von Backup füllen

root@asuka:~# mysql world < world.sql  -p
Enter password:

Tabellen einer Datenbank anzeigen