Description
after the installation of the database, the following is used, the database command many, here only to operate a few simple commands, after all, too complicated to remember, I am very helpless ah. The database of the increase, deletion, change, check is necessary, but also some basic commands, and then do some examples.
Lab requirements: Centos7 install MySQL.
Let's do the authorization for the database. Remote Login
1. Mysql-u root-p #使用root用户登录数据库
Grant all privileges in . to ' root ' @ '% ' identified by ' qwe123 ' with GRANT option; #授权身份为root, the password is qwe123,% to allow all nets to log on, two asterisks for all databases and all tables
.
.
2. To know the virtual machine IP address of the installation database, use this IP for remote login
.
.
3. The example here is the host, open the host cmd command prompt interface, to ensure that the virtual machine can be interconnected with, you can ping, and then enter the command
Mysql-h 192.168.200.128-u Root-p
Remote Authorization Login Succeeded
.
.
Command operations to start the database below
.
1. First, add and view the database
.
.
2. Go to the database, create tables, view table structure operations
.
.
3. Insert data into the table and view the data in the table
.
.
4. Data unavoidable to change
.
.
5. Setting the primary key
.
.
6. Sort the data in a table
.
.
7. View the data for the specified row, and sum and average the results
.
.
8. Delete the primary key, delete the column, and view the results
.
.
9. Delete the table to see the results
.
.
10. Finally delete the database and view the results
.
.
A short operation, a lack of a lot to forgive
MySQL 5.7 Operation Command