Quick start to mysql-8.0 basic operation
1 mysql download and installation
Go to mysql official website Download the corresponding version. The version I choose is mysql-8.0.18-winx64
Unzip the downloaded package, enter the internal bin directory in the cmd window, and start the mysql background service with the following command
D:\mysql-8.0.18-winx64\bin>mysqld
Open a new cmd window, enter the internal bin directory, and use the following command
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>
Successfully entered mysql interactive mode.
2 mysql basic command
mysql> show databases;//Show all databases +--------------------+ | Database | +--------------------+ | bj18 | | db111 | | information_schema | | mysql | | mytest | | performance_schema | | sys | | webby | +--------------------+ 8 rows in set (0.03 sec) mysql> create database mydatabase;//Create a database named 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;//Delete the specified database 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;//Open mydatabase database database //Recreate mydatabase database Database changed //Create a data table and specify several fields 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;//View all tables in the mydatabase database +----------------------+ | Tables_in_mydatabase | +----------------------+ | student | +----------------------+ 1 row in set (0.01 sec) mysql> desc student;//View the structure of the specified table +--------+--------------+------+-----+---------+----------------+ | 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) //Insert record in table mysql> insert into student values(1,'joan',0,89.2); Query OK, 1 row affected (0.01 sec) //Query records in table mysql> select id,name,sex,degree from student; +----+------+-----+--------+ | id | name | sex | degree | +----+------+-----+--------+ | 1 | joan | 0 | 89.20 | +----+------+-----+--------+ 1 row in set (0.00 sec) //Delete specified table mysql> drop table student; Query OK, 0 rows affected (0.02 sec) mysql> show tables; Empty set (0.00 sec) mysql>
This is just the most basic command. For example, select has many uses, but emmmmm is not listed one by one
Published 2 original articles, won praise 0, visited 155