mysql8.0初始化授权
初始化:
sys.stdout.write('Initializing MySQL database...\n') self.cmd = '/usr/local/mysql/bin/mysqld --initialize-insecure --datadir=%s --basedir=%s --user=%s' %(self.datadir, self.basedir, self.mysqluser)
启动:
self.cmd = '/usr/local/mysql/bin/mysqld_safe --defaults-file=%s --log-error=%s --slow_query_log_file=%s --socket=%s --port=%d --datadir=%s --pid-file=%s & ' %(self.mysqlconfigfile, self.logfile, self.slow_query, self. mysql_socket, self.mysql_port, self.datadir, self.pidfile)
授权:
import mysql.connector conn = mysql.connector.connect(host=self.mysqlhost, port=self.mysqlport, user=self.mysqluser, unix_socket=self.sock_file) cur = conn.cursor() ALTER_sql = "ALTER USER 'root'@'localhost' identified by '%s';"%self.root_pwd #print ALTER_sql cur.execute(ALTER_sql) grant_sql = "update mysql.user set host='%s' where user='root';" %'%' #print grant_sql cur.execute(grant_sql)
一些事情一直在干,说不定以后就结果了呢
本文来自博客园,作者:chenjianwen,转载请注明原文链接:https://www.cnblogs.com/chenjw-note/p/16225304.html