In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
In this article Xiaobian for you to introduce in detail the "mysql delete root users what is the method", detailed content, clear steps, details handled properly, I hope that this "mysql delete root users what is the method" article can help you solve doubts, following the editor's ideas slowly in-depth, together to learn new knowledge bar.
Mysql delete root user method: 1, use "CREATE USER" statement to create a user with the same rights as root user; 2, use "drop user" statement to delete root user, syntax "DROP USER root user account".
The operating environment of this tutorial: windows7 system, mysql8 version, Dell G3 computer.
Delete the default root user for MySQL
Requirements Analysis:
Root passwords have appeared in many places, such as shared technical documents, emails, screenshots.
The administrator account name root installed by default in MySQL is well known. To enhance security, you need to change a user name, such as superuser, or one with company characteristics. For example, xxx_admin.
Coping strategies:
First create a user with the same privileges as the root user.
GRANT ALL PRIVILEGES ON *. * TO'xinstant adminstration xxxx' 127.0.0.1 'IDENTIFIED BY' xxxx'
Delete the default root user.
Drop user root@'127.0.0.1';drop user root@'localhost';drop user root@'::1'
User account number:
The format is user_name'@'host_name.
The user_name here is the user name and the host_name host name, which is the name of the host that the user uses to connect to the MySQL.
If during the creation process, only the user name is given, but no hostname is specified, then the hostname defaults to "%", indicating a set of hosts, that is, opening permissions to all hosts.
Pay attention to the problems:
1. View
For a view that used to use the root account DEFINER, if you delete the root, it will indicate that the view cannot be used and has no permissions. So pay attention to check whether there is a view in advance, and if so, you need to modify the DEFINER property of the view.
Modifying a view is an instant operation, unless the view is locked by other sql statements.
View view
Select TABLE_SCHEMA, TABLE_NAME, VIEW_DEFINITION, DEFINER from information_schema.VIEWS
Modify the view (not modified for non-root)
ALTER DEFINER= `x _ admin` @ `127.0.0.1` SQL SECURITY DEFINER VIEW v_name AS...
2. Stored procedures / functions
The situation is similar to the view
View stored procedures / views
Select ROUTINE_SCHEMA,ROUTINE_NAME,ROUTINE_TYPE,DEFINER from information_schema.ROUTINES
Or
Select db,name,type,definer from mysql.proc
Modify the storage routine, you can modify mysql.proc directly
Update mysql.proc set definer='x_admin@127.0.0.1'where db='db_name'
If you modify all libraries
Update mysql.proc set definer='x_admin@127.0.0.1'
2. Script for connecting to MySQL with root users
This kind of problem is easy to solve. You can create an account for the script separately to perform the operations specified in the script. The user name can be named by script_, or script name. As long as you have enough permissions, don't assign too many permissions.
4. Method: a script to add users. (cooperate with batch execution)
#! / usr/bin/python#-*- coding: UTF-8-*-# This program# Version: 2.0.0 (2012-10-10) # Authors: lianjie.ning@qunar Com # History:# import osimport socketimport subprocessimport sysimport tracebackfrom ConfigParser import ConfigParserclass Finger (object): 'finger.py' def _ init__ (self): print' -% s % s'% (socket.gethostname (), self.__doc__) def load_config (self, file= "finger.ini"): if not os.path.exists (file): print file, "is not exists, but is created, please fix it" temp_ini =''[conn_db] login_pwd = exec_sql =''open (file,' w') .write (temp_ini) os.chmod (file) 0600) sys.exit () config = ConfigParser () config.read (file) if config.has_section ('conn_db') is True: if config.has_option (' conn_db', 'login_pwd') is True: login_pwd = config.get (' conn_db', 'login_pwd') if config.has_option (' conn_db' 'exec_sql') is True: exec_sql = config.get (' conn_db', 'exec_sql') return (login_pwd, exec_sql) def grant_user (self, login_pwd) Exec_sql): if os.path.exists ('/ usr/local/bin/mysql'): mysql ='/ usr/local/bin/mysql' elif os.path.exists ('/ usr/bin/mysql'): mysql ='/ usr/bin/mysql' elif os.path.exists ('/ bin/mysql'): mysql ='/ bin/mysql' else: Print "command not fount of mysql" sys.exit () user = 'xxxx' conn_port = [3306, 3307, 3308, 3309, 3310] for i in conn_port: ss = socket.socket (socket.AF_INET Socket.SOCK_STREAM) address = ('127.0.0.1, int (I)) status = ss.connect_ex (address) ss.settimeout (3) ss.close () if status = 0: conn_mysql ='% s-u% s-p% s-h227.0.0.1-P% d-N-s-e "% s"% (mysql, user, login_pwd I, exec_sql) p = subprocess.call (conn_mysql, shell=True) Stdout=open ("/ dev/null") if p = = 0: print "- checking port:% s is NORMAL"% I else: print "- checking prot:% s is ERROR"% iif _ name__ = ='_ main__': try: process = Finger () (login_pwd) Exec_sql) = process.load_config () process.grant_user (login_pwd, exec_sql) except Exception, e: print str (e) traceback.print_exc () sys.exit () here This article "what is the method for mysql to delete root users" has been introduced. If you want to master the knowledge points of this article, you still need to practice and use it yourself. If you want to know more about related articles, welcome to follow the industry information channel.
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.