mySQL is een grote database in Linux. De database is één van de 4 kernonderdelen van de LAMP-server: Linux Apache MySQL PHP.
# apt-get install mysql-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
libdbd-mysql-perl libdbi-perl libhtml-template-perl libnet-daemon-perl
libplrpc-perl mysql-client-5.1 mysql-server-5.1 mysql-server-core-5.1
The following NEW packages will be installed:
libdbd-mysql-perl libdbi-perl libhtml-template-perl libnet-daemon-perl
libplrpc-perl mysql-client-5.1 mysql-server mysql-server-5.1 mysql-server-core-5.1
0 upgraded, 10 newly installed, 0 to remove and 12 not upgraded.
Need to get 21.6MB of archives.
After this operation, 51.2MB of additional disk space will be used.
Do you want to continue [Y/n]? y
Get:1 http://ftp.debian.org/debian/ testing/main libnet-daemon-perl all 0.43-1 [46.6kB]
Get:2 http://ftp.debian.org/debian/ testing/main libplrpc-perl all 0.2020-2 [36.0kB]
Get:3 http://ftp.debian.org/debian/ testing/main libdbi-perl i386 1.612-1 [879kB]
Get:4 http://ftp.debian.org/debian/ testing/main libdbd-mysql-perl i386 4.016-1 [138kB]
Get:5 http://ftp.debian.org/debian/ testing/main mysql-client-5.1 i386 5.1.49-1 [8,301kB]
Get:6 http://ftp.debian.org/debian/ testing/main mysql-server-core-5.1 i386 5.1.49-1 [3,933kB]
Get:7 http://ftp.debian.org/debian/ testing/main mysql-server-5.1 i386 5.1.49-1 [7,814kB]
Get:8 http://ftp.debian.org/debian/ testing/main libhtml-template-perl all 2.9-2 [65.9kB]
Get:9 http://ftp.debian.org/debian/ testing/main mysql-server all 5.1.49-1 [64.4kB]
Fetched 21.6MB in 36s (589kB/s)
Preconfiguring packages ...
Selecting previously deselected package libnet-daemon-perl.
(Reading database ... 166436 files and directories currently installed.)
Unpacking libnet-daemon-perl (from .../libnet-daemon-perl_0.43-1_all.deb)
Selecting previously deselected package libplrpc-perl.
Unpacking libplrpc-perl (from .../libplrpc-perl_0.2020-2_all.deb) ...
Selecting previously deselected package libdbi-perl.
Unpacking libdbi-perl (from .../libdbi-perl_1.612-1_i386.deb) ...
Selecting previously deselected package libdbd-mysql-perl.
Unpacking libdbd-mysql-perl (from .../libdbd-mysql-perl_4.016-1_i386.deb)
Selecting previously deselected package mysql-client-5.1.
Unpacking mysql-client-5.1 (from .../mysql-client-5.1_5.1.49-1_i386.deb) ...
Selecting previously deselected package mysql-server-core-5.1.
Unpacking mysql-server-core-5.1 (from .../mysql-server-core-5.1_5.1.49-1_i386.deb) ...
Selecting previously deselected package mysql-server-5.1.
Unpacking mysql-server-5.1 (from .../mysql-server-5.1_5.1.49-1_i386.deb) ...
Selecting previously deselected package libhtml-template-perl.
Unpacking libhtml-template-perl (from .../libhtml-template-perl_2.9-2_all.deb) ...
Selecting previously deselected package mysql-server.
Unpacking mysql-server (from .../mysql-server_5.1.49-1_all.deb) ...
Processing triggers for man-db ...
Processing triggers for menu ...
Setting up libnet-daemon-perl (0.43-1) ...
Setting up libplrpc-perl (0.2020-2) ...
Setting up libdbi-perl (1.612-1) ...
Setting up libdbd-mysql-perl (4.016-1) ...
Setting up mysql-client-5.1 (5.1.49-1) ...
Setting up mysql-server-core-5.1 (5.1.49-1) ...
Setting up mysql-server-5.1 (5.1.49-1) ...
Starting MySQL database server: mysqld.
Setting up libhtml-template-perl (2.9-2) ...
Processing triggers for menu ...
Tijdens de installatie wordt er een root-mysql paswoord gevraagd:
+---------------------------- Configuring mysql-server-5.1 -----------------------------+
| While not mandatory, it is highly recommended that you set a password for the MySQL |
| administrative "root" user. |
| |
| If this field is left blank, the password will not be changed. |
| |
| New password for the MySQL "root" user: sdf12345 |
| ------------------------------------------------------------------------------------- |
| <Ok> |
+---------------------------------------------------------------------------------------+
Als je systeem hier niet om vraagt kun je dit paswoord ook instellen via de shell zoals hieronder in punt 3, hierna volgend.
# mysqladmin -u root password sdf12345
# mysql -u root -p mysql
Enter password:
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 48
Server version: 5.1.49-1 (Debian)
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> create database linux31;
Query OK, 1 row affected (0.00 sec)
mysql> insert into studenten values ('schneider','mike');
Query OK, 1 row affected (0.00 sec)
mysql> insert into studenten values ('markaj','aferdita');
Query OK, 1 row affected (0.00 sec)
mysql> insert into studenten values ('sensio','denis');
Query OK, 1 row affected (0.00 sec)
mysql> insert into studenten values ('shyaka','bernard');
Query OK, 1 row affected (0.00 sec)
mysql> insert into studenten values ('akram','shoaib');
Query OK, 1 row affected (0.01 sec)
mysql> insert into studenten values ('kubwimana','flora');
Query OK, 1 row affected (0.00 sec)
mysql> insert into studenten values ('viwassi','horatio');
Query OK, 1 row affected (0.00 sec)
mysql> describe studenten;
+----------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+-------+
| naam | varchar(20) | NO | | | |
| voornaam | varchar(20) | NO | | | |
+----------+-------------+------+-----+---------+-------+
2 rows in set (0.00 sec)
Je moet ingelogd zijn als mysql root gebruiker om dit commando uit te voeren.
mysql> CREATE USER 'user2'@'localhost' IDENTIFIED BY 'sdf12345';
Query OK, 0 rows affected (0.00 sec)
mysql> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'localhost' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)
mysql> DELETE FROM studenten WHERE naam='sensio';
Query OK, 1 row affected (0.00 sec)