I am trying to run
GRANT ALL PRIVILEGES ON * . * TO 'root'#'localhost';
from a remote server to localhost/phpmyadmin but getting ERROR 1045 (28000): Access denied for user 'root'#'%' (using password: NO).
mysql> show grants;
+----------------------------------+
| Grants for root#% |
+----------------------------------+
| GRANT USAGE ON *.* TO 'root'#'%' |
+----------------------------------+
How can I resolve this problem? I have gone through a lot of suggestions over internet but can't actually figure out.
I think, you forgot to flush privileges.
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'#'localhost' with GRANT OPTION;
mysql> FLUSH PRIVILEGES;
Note:
I have included with GRANT OPTION because as doc says:
The GRANT OPTION privilege enables you to give to other users or remove from other users those privileges that you yourself possess.
Edit 1:
Depending on comments, seems like you have forgotten the root password. So try to reset like this:
Stop the MySQL Server.
sudo /etc/init.d/mysql stop
Start the mysql without password
sudo mysqld_safe --skip-grant-tables &
Login to mysql as root:
mysql -u root
Set new password to root
UPDATE mysql.user SET Password=PASSWORD('password') WHERE User='root';
Flush privileges.
FLUSH PRIVILEGES;
Finally, restart mysql normally.
If you have root credential , then Set the privileges like mentioned below.
grant all privileges on db.* to user#'%' identified by 'pass';
Thanks
Related
I'm working on a MySQL server I haven't configured my self and I'm a bit of a noob when it comes to SQL.
I've created a database like this:
root#localhost:~# mysqladmin -u root -p create drupal
And then tried to grant privileges like this:
root#localhost:~# mysql -u root -p
MariaDB [(none)]> GRANT ALL PRIVILEGES ON drupal.* TO root IDENTIFIED BY ...;
But get this error:
ERROR 1044 (42000): Access denied for user 'root'#'localhost' to database 'drupal'
[Update] I get this error with all forms of GRANT commands.
But according to SHOW GRANTS I should have privileges:
MariaDB [(none)]> SHOW GRANTS;
+---------------------------------------------------------------------------
-------------------------------------------+
| Grants for root#localhost
|
+---------------------------------------------------------------------------
------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'#'localhost' IDENTIFIED BY PASSWORD
'*...' |
+---------------------------------------------------------------------------
-------------------------------------------+
1 row in set (0.00 sec)
MySQL version is: mysql Ver 15.1 Distrib 10.1.26-MariaDB
On Debian 9.5
The problem was that the root user didn't have Grant privileges.
SELECT host,user,password,Grant_priv,Super_priv FROM mysql.user;
I fixed it with this command:
UPDATE mysql.user SET Grant_priv='Y', Super_priv='Y' WHERE User='root';
FLUSH PRIVILEGES;
GRANT ALL ON *.* TO 'root'#'localhost';
You have to log out and in again for it to work.
I'm trying to install MySQL to my computer, and I am following these steps.
After I install and start MySQL, I Go back to Terminal and type:
sudo /usr/local/mysql/bin/mysql -u root -p
Terminal asks me to type my password, then I type my Mac PW, and then I get this error:
Access denied for user 'root'#'localhost' (using password: YES)
I apologize in advance, I am a beginner and have NO idea what to do next. I've done some research online and can't quite figure it out.
here's a link to the steps I'm following. I am stuck on Install MySQL # 9:
https://websitebeaver.com/set-up-localhost-on-macos-high-sierra-apache-mysql-and-php-7-with-sslhttps
Check your Grants
mysql> show grants;
+----------------------------------------------------------------------------------------------------------+
| Grants for root#localhost |
+----------------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'#'localhost' WITH GRANT OPTION |
| GRANT PROXY ON ''#'' TO 'root'#'localhost' WITH GRANT OPTION |
+----------------------------------------------------------------------------------------------------------+
2 rows in set (0.07 sec)
if no set then set them with:
GRANT ALL PRIVILEGES ON *.* TO 'root'#'localhost' WITH GRANT OPTION;
I want to execute command
GRANT ALL PRIVILEGES ON *.* TO 'root'#'%' WITH GRANT OPTION;
But I have error:
ERROR 1045 (28000): Access denied for user 'root'#'%' (using password: NO)
When I check my grants I have USAGE, nothing more.
MariaDB [(none)]> SHOW GRANTS;
+----------------------------------+
| Grants for root#% |
+----------------------------------+
| GRANT USAGE ON *.* TO 'root'#'%' |
+----------------------------------+
Command
CREATE DATABASE test;
Does not work too.
GRANT ALL PRIVILEGES ON *.* TO root#localhost IDENTIFIED BY '...' WITH GRANT OPTION;
But, if you don't have SUPER privilege to get in to do it, see the manual page for how to get in (from the same server) using --skip-grant-tables
The error message tells you that you don't have the right privileges to modify user grants.
You need the GRANT OPTION and ALL PRIVILEGES grants to be able to grant them to other user (yourself included).
I fixed it by commands
sudo apt-get remove --purge mysql-\*
sudo apt-get install mysql-server mysql-client
found at
https://askubuntu.com/questions/643251/having-trouble-installing-and-removing-mysql-in-ubuntu
But I am curious if there is no such invasive solution.
I have installed wampserver. i revoke the the delete privilege from root user. now i want to grant same privilege back to root user but it gives the error:
i tried the following command
GRANT ALL PRIVILEGES ON *.* TO 'root'#'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
but the command gives the
#1045 - Access denied for user 'root'#'localhost' (using password: YES)
there are two root users
root localhost
root 127.0.0.1
root localhost do not have DELETE privilege. root 127.0.0.1 have all privileges. i tried with http://127.0.0.1/phpmyadmin but the same error occurs. is there a way to reset root user privileges.
I have had issues with GRANT ... TO 'user'#'%' ... before. Try to additionally issue the following GRANT statement:
GRANT ALL PRIVILEGES ON *.* TO 'root'#'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION;
For me, this did the trick. Somehow mysql seems picky when it comes to localhost
After executing the following mysql statement to create database and giving privileges to user can't access mysql
create database my_db;
GRANT ALL PRIVILEGES ON my_db.* TO 'user'#'%' IDENTIFIED BY 'mypasswd';
GRANT SELECT ON my_db.* TO 'user'#'%' IDENTIFIED BY 'mypasswd';
FLUSH PRIVILEGES;
mysql -u user -p mypasswd drops me
Access denied for user 'user'#'localhost'
You need to give privileges separately for user to connect from localhost. % will not work.
`GRANT ALL PRIVILEGES ON my_db.* TO 'user'#'localhost' IDENTIFIED BY 'mypasswd';
GRANT SELECT ON my_db.* TO 'user'#'localhost' IDENTIFIED BY 'mypasswd';`
There is no space between -p and your password.
As you granted rights only for the database my_db, add the db also to connect directly to it.
mysql -u user -pmypasswd my_db
I tried this:
GRANT ALL ON my_db.* TO 'user'#'%' IDENTIFIED BY 'mypasswd';
FLUSH PRIVILEGES;
And afterwards
./mysql -uuser -pmypasswd
worked ok for me.
If it doesn't, try with localhost:
GRANT ALL ON my_db.* TO 'user'#'localhost' IDENTIFIED BY 'mypasswd';
FLUSH PRIVILEGES;