centos7 installer mysql
[root@localhost ~]# yum -y install mariadb mariadb-server
Démarrez mysql
[root@localhost ~]# systemctl start mariadb
[root@localhost ~]# mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.65-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>
opération de base mysql
Créer une base de données
MariaDB [(none)]> create database ku;
Query OK, 1 row affected (0.00 sec)
Créer une base de données UTF8
MariaDB [(none)]> create database ku1 character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)
Voir toutes les bibliothèques
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| ku |
| ku1 |
| mysql |
| performance_schema |
| test |
+--------------------+
6 rows in set (0.00 sec)
Supprimer la base de données
MariaDB [(none)]> drop database ku;
Query OK, 0 rows affected (0.00 sec)
Créez trois types de tables: innodb, myisam, memory
先进入一个数据库
MariaDB [(none)]> use ku1;
Database changed
MariaDB [ku1]> create table test1(id int(10),name varchar(10)) engine=mylsam;
Query OK, 0 rows affected, 2 warnings (0.00 sec)
MariaDB [ku1]> create table test2(id int(10),name varchar(10)) engine=innodb;
Query OK, 0 rows affected (0.00 sec)
MariaDB [ku1]> create table test3(id int(10),name varchar(10)) engine=memory;
Query OK, 0 rows affected (0.00 sec)
Afficher la structure du tableau
MariaDB [ku1]> desc test2;
+-------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| id | int(10) | YES | | NULL | |
| name | varchar(10) | YES | | NULL | |
+-------+-------------+------+-----+---------+-------+
2 rows in set (0.00 sec)
Supprimer la table
MariaDB [ku1]> drop table test1;
Query OK, 0 rows affected (0.00 sec)
Fonctionnement de routine: augmenter
MariaDB [ku1]> insert into test2 values(1,"小红花");
Query OK, 1 row affected (0.00 sec)
MariaDB [ku1]> insert into test2 values(2,"小绿花");
Query OK, 1 row affected (0.00 sec)
Opération de routine: supprimer
Supprimez toutes les données du tableau:
MariaDB [ku1]> delete from test2;
Query OK, 1 row affected (0.00 sec)
Opération de routine: changer
MariaDB [ku1]> update test2 set name="小黄花" where name="小红花";
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
Fonctionnement de routine: vérifier
Affichez les données de la table entière:
MariaDB [ku1]> select * from test2;
+------+-----------+
| id | name |
+------+-----------+
| 1 | 小黄花 |
| 2 | 小绿花 |
+------+-----------+
2 rows in set (0.00 sec)
Spécifiez l'identifiant à afficher:
MariaDB [ku1]> select * from test2 where id=2;
+------+-----------+
| id | name |
+------+-----------+
| 2 | 小绿花 |
+------+-----------+
1 row in set (0.00 sec)
Spécifiez le nom à afficher:
MariaDB [ku1]> select * from test2 where name="小黄花";
+------+-----------+
| id | name |
+------+-----------+
| 1 | 小黄花 |
+------+-----------+
1 row in set (0.00 sec)