how to create new database user in mysql python

Step1

Set Mysql variable path

set path=%PATH%;C:\xampp\mysql\bin;

Step 2
Using command prompt login to databse

mysql -u root -p

Password NULL
create a database python

Step 3
Create new username and password
jack username
jackpassword is the password

c:\python>mysql -u root -p
Enter password: *
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 18
Server version: 10.1.34-MariaDB mariadb.org binary distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> GRANT ALL PRIVILEGES ON *.* TO 'jack'@'localhost' IDENTIFIED BY 'jackpassword';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]>

Step 4
create new database using Python mysql connection

import mysql.connector

mydb = mysql.connector.connect(
  host="localhost",
  user="jack",
  passwd="jackpassword"
)

mycursor = mydb.cursor()

mycursor.execute("CREATE DATABASE myschool")

See All answers

  1. Hello! Behold is an important offers – the excellent collection of world’s top slots, roulette and blackjack games

My Thought

Your email address will not be published. Required fields are marked *

Our Tool : hike percentage calculator