use mysql;
insert into user (host, user, authentication_string, select_priv, insert_priv, update_priv) values ('localhost', 'name', password('password'), 'Y', 'Y', 'Y');
FLUSH PREVILEGES;
# 不可行时可以进行@添加
create user 'name'@localhost identified by 'password';
grant all privileges on name.* to 'name'@localhost identified by 'password';
flush privileges;
创建数据库
#!/usr/bin/python3import pymysql# 打开数据库连接db = pymysql.connect("localhost","testuser","test123","TESTDB" )# 使用 cursor() 方法创建一个游标对象 cursorcursor = db.cursor()# 使用 execute() 方法执行 SQL,如果表存在则删除cursor.execute("DROP TABLE IF EXISTS EMPLOYEE")# 使用预处理语句创建表sql ="""CREATE TABLE EMPLOYEE ( FIRST_NAME CHAR(20) NOT NULL, LAST_NAME CHAR(20), AGE INT, SEX CHAR(1), INCOME FLOAT )"""cursor.execute(sql)# 关闭数据库连接db.close()