In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Let's talk about how to use simple statements in MySQL. The secret of the text is that it is close to the topic. So, no gossip, let's go straight to the following, I believe you will benefit from reading this article on how to use simple sentences in MySQL.
1.mysql multi-instance login
Mysql-uroot-pendant 123456'-S / data/3306/mysql.sock
two。 View the version and login users
Select version ()
Select user ()
3. Create GBK character set database rich3
Create database rich3 CHARACTER SET = gbk COLLATE = gbk_chinese_ci
Show create database rich3; / / View the created database rich3
4. Create user rich3 and manage all permissions of database rich3
Grant all on. To rich3@localhost identified by '123456'
5. Check which users are in the current database
Select user,host from mysql.user
6. Access to rich3 database
Use rich3
7. Create innodb engine character set as GBK table test, fields are id and name varchar (16), view table structure and SQL statement
CREATE TABLE test (
Id int (4) DEFAULT NULL
Name varchar (16) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=gbk
Show create table test; / / find the created table test
8. Insert a piece of data 1 dint abcd
Insert into test values (1)
9. Insert data in bulk 2, hello, 3recoverrichrich
Insert into test values (2Jing 'Hello'), (3JING richness)
Select * from test; / / View all data in the test table
10. Query records named richrich and records with id greater than 1
Select from test where name=richrich'
Select from test where id > 1
11. Change the name richrich to hello if id is greater than 1
Update test set name='hello' where id=1
Select * from test
twelve。 Insert age field with type int (4) before field name
Desc test; / / View table structure
Alter table test add age int (4) after id
13. Backup rich3 library and mysql library
Mysqldump-uroot-pendant 123456'-S / data/3306/mysql.sock-- events-B rich3 mysql > / opt/bak_db_rich3_mysql.sql
14. Delete all data in the table and view
Truncate table test; / / clear the table
Desc test; / / View table structure
Select * from test;// view all the contents of the table test
Show tables;// views all the tables in the current library
15. Delete the database rich3 and view
Show databases
Drop database richy2
16. Restore the above deleted data on the command line
Mysql-uroot-pendant 123456'-S / data/3306/mysql.sock
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.