Db=pymysql. Connect (host="localhost", user="LHX", "=" Ly123456 ")
Cursor=the cursor (#) using the cursor () method to obtain your cursor
Print (' create account to start! ')
SQL="create user '% s' @' % s' identified by '% s'" % (self. Username. The get (),' % ', the self. The password. The get ())
Print (' 111 ')
Cursor. The execute (SQL) # can create on all machines can be connected user password
Print (' account created successfully! ')
SQL="to grant all privileges on *. * '% s' @' % s'" % (self. Username. The get (), '%')
Print (SQL)
Print (' 222 ')
Cursor. The execute (SQL) # to create a user name and password assigned permissions
Print (' permissions assigned success! ')
The close ()
This code in the above account, the password is to create a success, but the following code, to the account will assign permissions are not, but I have a print run (SQL) is displayed in the window of the string to copy and paste the mysql command line is to be performed, that statement is no problem, but is unable to perform in python, appear the following error:
Pymysql. Err. OperationalError: (1045, "Access denied for user 'LHX' @ '%' (using password: YES)")