grant all permissions to a user on mysql database

Posted on 2010-11-08
Medium Priority
Last Modified: 2012-05-10
Hi, I want to grant all permissions to a user on mysql database. I have logged on as administrator to the computer (i.e not on a domain). Computer is windows xp pro.

I know the following works for granting on an IP address

GRANT ALL ON mydatabase.* TO 'root'@'';

I tried

GRANT ALL ON mydatabase.* TO 'root'@'administrator';

that didn't work though.

Question by:RupertA
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
LVL 29

Expert Comment

ID: 34086299
Have  you tried:
    ON mydatabase.*
    TO root@localhost
     IDENTIFIED BY 'newpassword';

Author Comment

ID: 34086364
hi sammy, why would I do the

IDENTIFIED BY 'newpassword';


LVL 29

Expert Comment

ID: 34086767
wouldn't you want the user to have password?
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

LVL 29

Expert Comment

ID: 34086777
so basically, if you wish to grant permission to a user called root, then you need to identify that user by his/her password.

LVL 29

Accepted Solution

sammySeltzer earned 1000 total points
ID: 34086800
If you don't wish to identify the user by password, then I think this will work:
GRANT ALL PRIVILEGES ON mydatabase.* TO root@localhost

If it is not localhost, then enter servername there.
LVL 29

Expert Comment

ID: 34086821
One last point here.

Reason yours is not working when you substitute ip address with administrator is that you are confusing the system.

It should either be ip address or servername:

Assisted Solution

wolfgang_93 earned 1000 total points
ID: 34086907
By default the MySQI id root already has full access to all objects in all databases.

Generally you do not want to change anything about root other than to give it a
password (be default root does not have a password and it is VERY important
that it has one).

To setup other users and give them access to a particular database (I am perhaps
including some stuff that you have already done toward setting things up):

Issue the following commands as the id "root" (which is allowed to create new
users and give them access):

Create a new user "administrator" with password "xyz" allowed to access the system
from any client:
   GRANT USAGE ON *.* TO administrator@'%' IDENTIFIED BY 'xyz'

Create a new database called "mydatabase" if you haven't done it already:
   CREATE DATABASE mydatabase

Give user "administrator" via any client machine full access to the new database:
   GRANT USAGE ON *.* TO administrator@'%' IDENTIFIED BY 'xyz'

Finally flush the cache and make the new privileges stick:


Author Comment

ID: 34092214
Sammy's did solve this but Wolfgang's info was very helpful to aid my understanding so I am going to do 50/50.

Featured Post

Percona Live Europe 2017 | Sep 25 - 27, 2017

The Percona Live Open Source Database Conference Europe 2017 is the premier event for the diverse and active European open source database community, as well as businesses that develop and use open source database software.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this blog post, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.
Backups and Disaster RecoveryIn this post, we’ll look at strategies for backups and disaster recovery.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question