Difference between revisions of "Mysql"

From Linuxintro
imported>ThorstenStaerk
imported>ThorstenStaerk
Line 13: Line 13:
 
Here is a short example how to work with mysql, including an SQL statement:
 
Here is a short example how to work with mysql, including an SQL statement:
 
<pre>
 
<pre>
staerk@tweedleburg:~> mysql                                                                                                                                   
+
$ mysql                                                                                                                                   
 
Welcome to the MySQL monitor.  Commands end with ; or \g.                                                                                                     
 
Welcome to the MySQL monitor.  Commands end with ; or \g.                                                                                                     
 
Your MySQL connection id is 1                                                                                                                                 
 
Your MySQL connection id is 1                                                                                                                                 

Revision as of 08:31, 1 May 2009

MySQL is a free database. This article describes how to install it, start it and how to connect to it. It has been tested with SUSE Linux 11.1 but should work with any Linux.

How to install mysql

sudo /sbin/yast -i mysql

How to start the database

sudo /etc/init.d/mysql start

How to connect to mysql

mysql

How to work with mysql

Here is a short example how to work with mysql, including an SQL statement:

$ mysql                                                                                                                                   
Welcome to the MySQL monitor.  Commands end with ; or \g.                                                                                                     
Your MySQL connection id is 1                                                                                                                                 
Server version: 5.0.67 SUSE MySQL RPM                                                                                                                         

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

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema | 
| mysql              | 
| test               | 
+--------------------+
3 rows in set (0.01 sec)

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
mysql> show tables;
+---------------------------+
| Tables_in_mysql           |
+---------------------------+
| columns_priv              |
| db                        |
| func                      |
| help_category             |
| help_keyword              |
| help_relation             |
| help_topic                |
| host                      |
| proc                      |
| procs_priv                |
| tables_priv               |
| time_zone                 |
| time_zone_leap_second     |
| time_zone_name            |
| time_zone_transition      |
| time_zone_transition_type |
| user                      |
+---------------------------+
17 rows in set (0.00 sec)

mysql> select * from time_zone;
Empty set (0.00 sec)

mysql>