mysqlの-8.0基本操作クイックスタート
1 MySQLのダウンロードとインストール
移動するには、公式サイトのmysql対応するバージョンをダウンロードし、私は、バージョンのmysql-8.0.18-winx64は、選択した
アーカイブの解凍にダウンロードした後、CMDウィンドウでbinディレクトリの内部には、次のコマンドでmysqlを使用してバックグラウンドサービスを開始します
D:\mysql-8.0.18-winx64\bin>mysqld
cmdは、binディレクトリの内部に新しいウィンドウを開き、次のコマンドを使用するには
D:\mysql-8.0.18-winx64\bin>mysql -u root -p
Enter password: **********
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.18 MySQL Community Server - GPL
Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
首尾よくmysqlの対話モードに入りました。
2 MySQLのコマンドベース
mysql> show databases;//显示所有的数据库
+--------------------+
| Database |
+--------------------+
| bj18 |
| db111 |
| information_schema |
| mysql |
| mytest |
| performance_schema |
| sys |
| webby |
+--------------------+
8 rows in set (0.03 sec)
mysql> create database mydatabase;//创建一个数据库,命名为mydatabase
Query OK, 1 row affected (0.02 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| bj18 |
| db111 |
| information_schema |
| mydatabase |
| mysql |
| mytest |
| performance_schema |
| sys |
| webby |
+--------------------+
9 rows in set (0.00 sec)
mysql> drop database mydatabase;//删除指定数据库
Query OK, 0 rows affected (0.02 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| bj18 |
| db111 |
| information_schema |
| mysql |
| mytest |
| performance_schema |
| sys |
| webby |
+--------------------+
8 rows in set (0.00 sec)
mysql> use mydatabase;//打开mydatabase数据库
//mydatabase数据库重新创建
Database changed
//创建数据表,并指定几个域
mysql> create table student(
-> id int(4) not null primary key auto_increment,
-> name char(20) not null,
-> sex int(4) not null default '0',
-> degree double(16,2));
Query OK, 0 rows affected, 3 warnings (0.06 sec)
mysql> show tables;//查看mydatabase数据库中的所有表
+----------------------+
| Tables_in_mydatabase |
+----------------------+
| student |
+----------------------+
1 row in set (0.01 sec)
mysql> desc student;//查看指定表的结构
+--------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------+--------------+------+-----+---------+----------------+
| id | int(4) | NO | PRI | NULL | auto_increment |
| name | char(20) | NO | | NULL | |
| sex | int(4) | NO | | 0 | |
| degree | double(16,2) | YES | | NULL | |
+--------+--------------+------+-----+---------+----------------+
4 rows in set (0.01 sec)
//在表中插入记录
mysql> insert into student values(1,'joan',0,89.2);
Query OK, 1 row affected (0.01 sec)
//查询表中的记录
mysql> select id,name,sex,degree from student;
+----+------+-----+--------+
| id | name | sex | degree |
+----+------+-----+--------+
| 1 | joan | 0 | 89.20 |
+----+------+-----+--------+
1 row in set (0.00 sec)
//删除指定表
mysql> drop table student;
Query OK, 0 rows affected (0.02 sec)
mysql> show tables;
Empty set (0.00 sec)
mysql>
これは、このような選択だけでなく、様々な用途として、単に最も基本的なコマンド、である、とemmmmmからそれらをリストしていませんでした