In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Let's talk about the basic application of MySQL. The secret of the text is to be close to the topic. So, no more gossip, let's go straight to the following, I believe you will benefit from reading this article on the basic application of MySQL.
1. Log in to the MySQL CVM
[root@localhost] # mysql-u root-p
Enter password: / / enter the correct password when prompted
two。 Execute MySQL operation statement
After logging in to the "mysql >" environment as root, execute the "show master logs;" statement to query the log file information of the current database service.
3. Exit the "mysql" operating environment
Execute "exit" or "quit" commands in the "mysql >" operating environment to exit the mysql command tool and return to the shell environment.
4. View database structure
Show database statement: used to view the libraries contained in the current mysql CVM.
Show tables statement: used to view the tables contained in the current database. Before you can do this, you need to switch to the library you are using with the use statement.
Describe statement: the structure used to represent, that is, the information about the various fields (columns) that make up the table. You need to specify the name of the library. table name as a parameter
5. Create and delete libraries and tables
Create a new library
Create database auth; creates a table called auth.
Create a new table
Create table table name (field 1 name type, field 2 name type, … , PRIMARY KET (primary key name)
Delete a database
DROP database auth.users
Delete a data table
Drop table auth
6. Data record in table
Insert into statement: used to insert new data records into the table.
Insert into table name (field 1, field 2...) Values (the value of field 1, the value of field …)
Example: the specified field in the insert statement can be omitted. Insert into users values ('lucky',password'1234')
Select statement: use to find matching data records from the specified table.
Select field name 1, field name 2, … Conditional expression of from table name
Example: select * from auth.users
Update statement: used to modify and update data records.
Update table name set field name 1 = field value 1 [, field 2 = field value 2] where conditional expression
Example: update auth.users SET user_passwd=password ('') where user_name='lucky'
Delete statement: used to delete the data record specified at the middle level of the table.
Delete from table name where conditional expression
Example: delete from auth.users where user_name='lucky'
7. Database backup and recovery
Backup database
Format 1: export some tables in the library.
Mysqldump [option] Library name [Table name 1] [Table name 2]... > / backup path / backup file name
Format 2: export one or more complete libraries.
Mysqldump [option]-- databases library name 1 [library name 2]... > / backup path / backup file name
Format 3: back up all the libraries in the mysql CVM.
Mysqldump [options]-- all-database > / backup path / backup file name
Example: mysqldump-u root-p mysql user > mysql-user.sql
Mysqldump-u root-p-- databases auth > auth.sql
Restore the database
Mysql [option] [Library name] [Table name] < / backup path / backup File name
Mysql-u root-p test < mysql-user.sql
Is there anything you don't understand about the basic application of MySQL above? Or if you want to know more about it, you can continue to follow our industry information section.
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.