I am using PhpMyadmin. I canceled some structure privileges of the user root this afternoon and I want to recover these privileges. I always log in to PhpMyAdmin with the user identity of "root". But I get an error message when I attempt to recover my all privileges.
Error
SQL query: Edit
GRANT ALL PRIVILEGES ON * . * TO 'root'#'localhost' WITH GRANT OPTION
MAX_QUERIES_PER_HOUR 0
MAX_CONNECTIONS_PER_HOUR 0
MAX_UPDATES_PER_HOUR 0
MAX_USER_CONNECTIONS 0 ;
MySQL said: Documentation
#1045 - Access denied for user 'root'#'localhost' (using password:
YES)
What's wrong? How to solve this problem?
It looks like you locked your root user out from your database. To fix this you need direct access to the databases server (system'S root / Administrator acocount) and then start the MySQL server using the --skip-grant-tables option. Then MySQL won't check the user rights so you can give all rights back to the root user.
Note that you should use the MySQL root account really only when it's needed, daily operations should be delegated to other users to prevent such errors in future.
Related
I accidentally removed all privileges for root user in mysql database user table.
By helping best at MySQL Error: : 'Access denied for user 'root'#'localhost' I can now access database but I cannot grant all privileges to my root user at localhost.
Via PHPMyAdmin interface when I go and try to add, I get this error:
#1290 - The MariaDB server is running with the --skip-grant-tables option so it cannot execute this statement
But I cannot access database and phpmyadmin without skip-grant-tables option.
This is the query runs but returns error:
GRANT ALL PRIVILEGES ON *.* TO 'root'#'localhost' REQUIRE NONE WITH GRANT OPTION MAX_QUERIES_PER_HOUR 2147483647 MAX_CONNECTIONS_PER_HOUR 2147483647 MAX_UPDATES_PER_HOUR 2147483647 MAX_USER_CONNECTIONS 2147483647;
What should I do?
How do I grant permissions to users in MySQL?
This is the order in which I tried:
First, connect from EC2 SERVER to MYSQL CLIENT RDS.
After connecting, MYSQL created a user to give you permission.
An error occurs when giving the user permission.
My attempt:
mysql> CREATE USER 'injekim'#'125.128.63.112' IDENTIFIED BY 'k12345678!!';
Query OK, 0 rows affected (0.02 sec)
mysql> GRANT ALL PRIVILEGES ON *.* TO 'injekim'#'125.128.63.112' WITH GRANT OPTION;
ERROR 1045 (28000): Access denied for user 'root'#'%' (using password: YES)
ERROR 1045 (28000): Access denied for user 'root'#'%' (using password: YES)
Also, I found similar error information in stackoverflow, but I couldn't solve it.
MySQL ERROR 1045 (28000): Access denied for user 'bill'#'localhost' (using password: YES)
How can I authorize the user who created it?
It looks like you are not logged into the host machine. To use the root user, you should actually be logged into the machine (ssh or rdp) that is hosting the MySQL server.
Example, let's say I am setting at my Mac but need to give a new user access to a MySQL database that is running on a server with an IP address of 192.168.1.10. Assuming it's a Linux server I would ssh to the server from my Mac's terminal by running:
ssh myuser#192.168.1.10
You can now either:
Log into MySQL as root by running: mysql -u root -p (you will be prompted for the password)
Or,
You could become the root user. In my case, I would run the following:
sudo su. Now that you are the root user, you can log into MySQL by running:
mysql -p
If you need an example in a Windows environment, let me know. It will be the same basic idea, but using RDP instead of ssh. From your local machine, get a session on the actual server running MySQL and then log into MySQL as root from the server.
I want to allow remote connection from a certain IP.
I have a use coszi_crawl and DB name is same too.
I am logged into server using coszi_crawl user.
I have run this command
GRANT ALL PRIVILEGES ON coszi_crawl.* TO 'coszi_crawl'#'39.32.%' IDENTIFIED BY 'abcqwe' WITH GRANT OPTION;
But this is giving me this error
ERROR 1044 (42000): Access denied for user 'coszi_crawl'#'localhost' to database 'coszi_crawl'
P.S.:
Though I can access coszi_crawl DB from Browser using PHPmyadmin with user coszi_crawl
How can I can solve this problem?
You should use the root account on your database server to update the priviledges, by default the user coszi_crawldoes not have access to granting priviledges on databases.
It means You don't have GRANT OPTION privilege. Login to user having GRANT OPTION privileges, only that user can give grant to other users.
Generally or by default root user has all the privileges so use that user.
Grant privilege
I'm trying to create a database on my remote sql server - clearDB - on Heroku. I connected with this:
mysql --host='<<cleardbhostname>>' --user='<<lsdj234>> --password
My username and password are obtained from the result from running heroku config. When I tried to run
CREATE DATABASE mydb;
I got this:
ERROR 1044 (42000): Access denied for user '<<lsdj234>>'#'%' to database 'mydb'
When I ran SHOW GRANTS for current_user I got:
GRANT USAGE ON *.* TO '<<lsdj234>>'#'%' IDENTIFIED BY PASSWORD '*asfe4545235' WITH MAX_QUERIES_PER_HOUR 3600 MAX_USER_CONNECTIONS 10 |
| GRANT ALL PRIVILEGES ON `heroku_ljl4455lkj`.* TO '<<lsdj234>>'#'%'
What is happening? How do I resolve this?
The only database that your user can access (and even create) is heroku_ljl4455lkj
It can't create any other databases.
Access denied for user 'root'#'xxxxxxxxxxxxx' (using password: YES)
even though I have an entry in mysql.user table that has host as % and user as root.
I did grant all privileges on . to 'root'#'%';
I would need to see how you are trying to connect to the server to give you additional information. It is possible that the call to the client (or whatever you are using) is munged in some way.