background:
jupyter notebook uses python to operate mysql database
Error: 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
Then open mysql8 commandline client
>GRANT ALL PRIVILEGES ON *.* TO 'your_database'@'%' IDENTIFIED BY 'your_password';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IDENTIFIED BY 'your_password'' at line 1
Found out after inquiry
For mysql8 version, user permissions need to be granted first
#Create a user first
create user 'username'@'%' identified by '123456';
#Authorize again
grant all privileges on *.* to 'username'@'%' with grant option;
The exception information when granting is as follows:
ERROR 1410 (42000): You are not allowed to create a user with GRANT
You can use Windows powershell
First switch to the mysql bin path and then operate
PS F:\IT\software\mysql8\bin> .\mysql
ERROR 1045 (28000): Access denied for user 'ODBC'@'localhost' (using password: NO)
PS F:\IT\software\mysql8\bin> .\mysql -u root -p
password:*************
mysql> GRANT ALL PRIVILEGES ON *.* TO 'your_username'@'localhost';
Query OK, 0 rows affected (0.00 sec)mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)