In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Common Management applications of MySQL Database
1. Create a database
Create a database solin
Mysql > create database solin
Create a GBK character set called solin_gbk
Mysql > create database solin_gbk DEFAULT CHARACTER SET gbk COLLATE gbk_chinese_ci
Create a UTF8 character set called solin_utf8
Mysql > create database solin_utf8 DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci
2. Display the database
Command: show databases
Show the current database: select database ()
Check a library: show databases like'% solin%'
3. Delete the database
Mysql > drop database solin
4. Connect to the database
Mysql > use solin_gbk
Database changed
5. View the current database
Mysql > select database (); check that the connected database is equivalent to the pwd under linux
Mysql > select version (); view version
Mysql > select user (); View the current user, which is equivalent to the whoami under linux
6. Delete redundant accounts in the system.
Syntax: drop "user" @ "host domain name"
Mysql > select user,host from mysql.user
+-+ +
| | user | host |
+-+ +
| | root | 127.0.0.1 | |
| | root |:: 1 |
| | localhost |
| | root | localhost |
| | ysolin |
| | root | ysolin |
+-+ +
6 rows in set (0.00 sec)
Mysql > drop user'@ 'localhost'
Query OK, 0 rows affected (0.00 sec)
Mysql > select user,host from mysql.user
+-+ +
| | user | host |
+-+ +
| | root | 127.0.0.1 | |
| | root |:: 1 |
| | root | localhost |
| | ysolin |
| | root | ysolin |
+-+ +
5 rows in set (0.00 sec)
Note: if drop cannot be deleted (usually special characters or uppercase), you can delete it in the following way (for root, ysolin host as an example)
Mysql > delete from mysql.user where user='root' and host='ysolin'
Mysql > flush privileges
Business case Tips:
1. How to create a database in an enterprise?
(1) determine the character set according to the developed program
(2) specify the character set at compile time, for example:
-DDEFAUL_CHARSET=UTF8\
-DDEFAULT_COLLATION=GENERAL_CI\
Then when you build the library, you can create it by default, create database solin
(3) when compiling, there is no specified character set or a different character set from the program, how to solve it?
Specify the character set to create the database (the database should support the character set for creating the library).
Create a GBK character set called solin_gbk
Mysql > create database solin_gbk DEFAULT CHARACTER SET gbk COLLATE gbk_chinese_ci
Create a UTF8 character set called solin_utf8
Mysql > create database solin_utf8 DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci
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.