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 will explain in detail how mysql creates a database, adds users, and authorizes users. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.
First, create a mysql database
1. Create database syntax
-create a database named "testdb" and set the code set to utf8CREATE DATABASE IF NOT EXISTS testdb DEFAULT CHARSET utf8 COLLATE utf8_general_ci
Second, create users
1. New user
Create a user named: test password: 1234 create user 'test'@'localhost' identified by' 1234'
Note:
The "localhost" here means that the user can only log in locally and cannot log in remotely on another machine. If you want to log in remotely, change "localhost" to "%", which means you can log in on any computer. You can also specify that a machine can log in remotely.
two。 Query users
-- query user select user,host from mysql.user
3. Delete user
-- delete the user "test" drop user test@localhost;-- if the created user allows any computer to log in, delete the user as follows: drop user test@'%'
4. Change password
-- method 1: real-time password update; change the password of user "test" to "1122" set password for test = password ('1122');-- method 2, which needs to be refreshed; change the password of user "test" to "1234" update mysql.user set password=password (' 1234') where user='test'-- refresh flush privileges
5. User assigns permissions
-- Grant user test full permissions to database "testdb" through public network IP grant all privileges on 'testdb'.* to' test'@'%' identified by '1234permissions;-- refresh permission flush privileges;-- grant user "test" permission to create, modify and delete tables in database "testdb" through public network IP, as well as permission to add, delete, check and modify table data grant create,alter,drop,select,insert,update,delete on testdb.* to test@'%'
6. View user permissions
-- View user "test" show grants for test
Note: after modifying the permissions, be sure to refresh the service, or restart the service. Refresh the service with: flush privileges
This is the end of the article on "how to create a database, add users and authorize users in mysql". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it out 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.