python - mysql setting user name and password -


i have installed mysql on mac osx , can open in shell , gain access databases , tables come it.

now want create database in python using mysql-connector/python

before doing figured wise set user name , password in mysql.

i have tried using following error messages. goal set user name , password may provide mysql-connector python, , execute sql queries python environment. here tried @ mysql command prompt:

set password 'root'@'localhost' = password('newpwd');

and error message:

error 1044 (42000): access denied user ''@'localhost' database 'mysql'

so tried update method:

update mysql.user set password = password('newpwd') user = 'root';

and error message:

error 1142 (42000): update command denied user ''@'localhost' table 'user'

so know why denied , how can make changes create user , password may use in mysql connect in python environment?

sounds not authenticated. make sure authenticated root user

access denied user ''@'localhost' database 'mysql' should

access denied user 'root'@'localhost' database 'mysql' 

otherwise not logged in root, rather anonymous user.

ofc, when logged in root, won't message, username not have proper rights.

start query authentication

mysql -u username -ppassword -h hostnameorip databasename  

example:

mysql --port=3307 --host=127.0.0.1 -u root --password=thisismypass test -e "load data low_priority local infile '%pathuser%' table `user_log`...." 

in case

 mysql -u root "set password 'root'@'localhost' = password('newpwd');" 

Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -