unable to create database due access denied
Solution 1:
To login into MySQL as root user, you can use:
mysql -u root -p
and then enter your MySQL password.
To login as another user, you will have to create that user first and grant him privileges.
Create the user using - change newuser
to the username you want and password
to your password of choice.
CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';
Sadly, at this point newuser
has no permissions to do anything with the databases.
Therefore the first stage is to grant the user the privileges to do 'things'.
To grant all privileges (select, create, delete, update, drop, etc) on all databases and tables, run:
GRANT ALL PRIVILEGES ON * . * TO 'newuser'@'localhost';
To grant a specific privilege on a particular database and table, just run:
GRANT [type of privilege] ON [database name].[table name] TO '[username]'@'localhost';
If you ever need to deny or revoke a certain privilege, just run:
REVOKE [type of permission] ON [database name].[table name] FROM '[username]'@'localhost';
Source: https://www.digitalocean.com/community/articles/how-to-create-a-new-user-and-grant-permissions-in-mysql
Solution 2:
open the mysql in save mode
sudo mysqld_safe --skip-grant-tables
===============================
login mysql as root user
mysql -u root
===============================
grant all PRIVILEGES for that a/c
GRANT ALL PRIVILEGES ON `%`.* TO 'root'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION;
i think this will also work ...