In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article introduces what are the general knowledge and basic operation of mysql. The content is very detailed. Interested friends can use it for reference. I hope it will help you.
General knowledge and basic operation of mysql
Field Type
1.INT [(M)]
Normal size integer type
2.DOUBLE [(MMagar D)] [ZEROFILL]
Normal size (double precision) floating point number type
3.DATE
Date type. The range of support is' 1000-01-01'to '9999-12-31'. MySQL displays date values in 'YYYY-MM-DD' format, but allows you to assign values to DATE columns using strings or numbers
4.CHAR (M)
Fixed-length string type, when stored, always fill the right side with spaces to the specified length
5.BLOB TEXT
BLOB or TEXT type with a maximum length of 65535 (2 ^ 16-1) characters.
6.VARCHAR
Variable length string type.
1: display the database
SHOW DATABAS
2: currently selected database
Mysql > SELECT DATABASE ()
+-+
| | DATABASE () |
+-+
| | test |
+-+
| | DATABASE () |
+-+
| | test |
+-+
Table information contained in the current database:
Mysql > SHOW TABLES
+-+
| | Tables in test |
Mysql > SHOW TABLES
+-+
| | Tables in test |
+-+
| | mytable1 |
| | mytable2 |
+-+
Get table structure
Mysql > desc mytable1
+-+ +
| | Field mysql > desc mytable1 |
+-+ +
| | Field | Type | Null | Key | Default | Extra | |
+-+ +
| | S1 | varchar (20) | YES | NULL |
+-+
5. Import database tables
(1) create a .sql file
(2) generate a library such as auction.c:mysqlbin > mysqladmin-u root-p creat auction, prompt for a password, and then create it successfully.
(2) Import auction.sql file
C:mysqlbin > mysql-u root-p auction
< auction.sql。 通过以上操作,就可以创建了一个数据库auction以及其中的一个表auction。 6.修改数据库 (1)在mysql的表中增加字段: alter table dbname add column userid int(11) not null primary key auto_increment; 这样,就在表dbname中添加了一个字段userid,类型为int(11)。 7.mysql数据库的授权 mysql>Grant select,insert,delete,create,drop
On *. * (or test.*/user.*/..)
To user name @ localhost
Identified by 'password'
For example, to create a new user account so that you can access the database, you need to do the following:
Mysql > grant usage
-> ON test.*
-> TO testuser@localhost
Query OK, 0 rows affected (0.15 sec)
After that, a new user is created called testuser, who can only connect to the database from localhost and can connect to the test database. Next, we must specify what the user testuser can do:
Mysql > GRANT select, insert, delete,update
-> ON test.*
-> TO testuser@localhost
Query OK, 0 rows affected (0.00 sec)
This action enables testuser to perform SELECT,INSERT and DELETE as well as UPDATE query operations on tables in each test database. Now let's finish the operation and exit the MySQL client:
Mysql > exit
About mysql general knowledge and basic operations are shared here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
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.