How to grant root user in mysql database user table all privileges - mysql

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?

Related

How to grant root user all privileges while skip-grant-table is enabled

I want to grant all privileges to root user in mysql database while skip-grant-tables is enabled.
How can I do that?
When I disable skip-grant-tables options, I cannot login to mysql due to this error:
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES)
When I run this command, it affect zero rows:
GRANT ALL PRIVILEGES ON *.* TO 'root'#'localhost';
Also:
FLUSH PRIVILEGES;
does not flush or alter anything.
Database is Mariadb version 10.3.22.
setup 1: when skip-grant-tables is enabled
update user set authentication_string=password("root") where user="root";
flush privileges;
setup 2:
delete skip-grant-tables in my.cnf
setup 3:
restart mysql service

How i can give all privilages for a user to all databases in my shared hosting

I have a user and 10 databases in my cpanel and i want grant this user to all databases in my host using sql command.
I used this command :
grant all privileges on *.* to 'myacc_myuser'#localhost identified by 'mypass' with grant option;
But it give me this error :
#1045 - Access denied for user 'myacc'#'localhost'
How i can resolve this problem ?
Thanks.

MySQL: Access denied for user to database

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.

Error 1045 MySQL

I have a remote database which I connect through a sql management with a user and its password. The database has four tables and a view. To put the permissions I have executed the following command:
mysql> grant all privileges on databasename.* to 'username'#'%' identified by 'password' with grant option;
Then, all it's ok. When I connect to the database, I can see the data from the tables but if I explore the view, for example:
select * from viewname;
I get this error:
Error SQL (1045): Access denied for user 'username'#'%' (using password: YES)
I don't know what is the problem, because the rest of the database is OK.
Once you have given the desired privileges for your user, you will need to run this command within the MySQL command prompt:
Flush the privileges with this MySQL command: FLUSH PRIVILEGES;

I can not recover my all privileges in PhyMyAdmin

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.