473,804 Members | 3,162 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

copy user privileges to a newly created user.

Hello:

I have just created a user with specific permissions to certain tables
in different databases. Now I have to create serveral more users with
the same permission. Is there a command in MySQL that allows me to
create the new user by copying the privileges from a template user?

MySQL 4.0.16

usaims

Jul 23 '05 #1
2 9942
"usaims" <us****@yahoo.c om> wrote in message
news:11******** **************@ g47g2000cwa.goo glegroups.com.. .
Hello:

I have just created a user with specific permissions to certain tables
in different databases. Now I have to create serveral more users with
the same permission. Is there a command in MySQL that allows me to
create the new user by copying the privileges from a template user?


I believe you will want to script it using your favorite language - be it a
DOS batch file, VB script, VBA, BASH, Python, Perl. You want to pass 1 or
more GRANT statements to MySQL using a usr name and host as the input.

Here is a minimalist Linux/BASH example. Sorry - I don't remember enough DOS
batch file language except to say it would look exceedingly similar

------------------------------------------------------------------------
#! /bin/bash

# Did we specify the user name@host on the command line?
if [ $# -ne 1 ]
then echo 'Aborted! - Need to specify "usr@host" on the command line'
exit
fi

# The $1 parameter holds our usr@host variable
mysql -uYourUsr -pYourPwd <<USER_PERMIT
GRANT SELECT ON SomeDB.SomeTabl e TO "$1"
GRANT SELECT ON SomeOtherDB.Som eOtherTable TO "$1"
USER_PERMIT


Jul 23 '05 #2
"usaims" <us****@yahoo.c om> wrote in message
news:11******** **************@ g47g2000cwa.goo glegroups.com.. .
Hello:

I have just created a user with specific permissions to certain tables
in different databases. Now I have to create serveral more users with
the same permission. Is there a command in MySQL that allows me to
create the new user by copying the privileges from a template user?


I believe you will want to script it using your favorite language - be it a
DOS batch file, VB script, VBA, BASH, Python, Perl. You want to pass 1 or
more GRANT statements to MySQL using a usr name and host as the input.

Here is a minimalist Linux/BASH example. Sorry - I don't remember enough DOS
batch file language except to say it would look exceedingly similar

------------------------------------------------------------------------
#! /bin/bash

# Did we specify the user name@host on the command line?
if [ $# -ne 1 ]
then echo 'Aborted! - Need to specify "usr@host" on the command line'
exit
fi

# The $1 parameter holds our usr@host variable
mysql -uYourUsr -pYourPwd <<USER_PERMIT
GRANT SELECT ON SomeDB.SomeTabl e TO "$1"
GRANT SELECT ON SomeOtherDB.Som eOtherTable TO "$1"
USER_PERMIT

Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
7183
by: tracy | last post by:
hi, just wonder, can we copy a role then add some new priviledges to the new role. hm.. i means, example; now i have a role named role_a. Then I copy role_a to create role_b. After I created role_b from role_a, i would like to revoke some privileges in role_b without affecting role_a. Can I and how to write the script? regards, tracy
2
8571
by: Ted | last post by:
How do I grant all privileges for a schema that has a large number of existing tables, procedures, functions, etc to a newly created role, without having to issue a grant statement for each object and each privilege? I want the role to have all of the rights of the schema owner. Is there any kind of blanket granting of all privileges to a role?
1
2526
by: Taber, Mark | last post by:
I posted this earlier, and got no responses. While using pg_dump and pg_restore (or attempting to restore, more precisely), the process failed because of a missing user, user '128'. I never created such a user, and when going to Privileges, such a user does not exist in the list. However, while going out and checking some of the tables, this user shows up as a user with privileges on them (however, not on all tables). How do I get rid of...
2
693
by: Ray Muforosky | last post by:
Hello everyone. I created a new user with the grant command and yet, I can't login into the database I must mention that the user was created but all the privileges are set to 'N'. This is what i get trying to login with the new user I created. "ERROR 1045 (28000): Access denied for user 'nsac'@'localhost' (using password: YES)"
2
1558
by: sankaba | last post by:
Hi, I have created a new user for a database that i hav created in DB2, by expanding the database tree diagram in control center right upto DB users folder, and then right clicking it and selecting "Add...". It opens up a window, where we hav to specify the name of the user, and the various privileges to the new user. if we click"ok" the new user is created. BUT THE PROBLEM IS I DON'T KNOW WAT IS THE PASSWORD (or DEFAULT PASSWORD)...
7
3188
by: Oracle10 | last post by:
Hi all, I have created a user and I want that all the privileges(select,update,insert,delete etc) should be automatically granted to this newly created user.Please anybody can tell me how can I do that? Thanks in Advance...
33
11870
by: JamesB | last post by:
I am writing a service that monitors when a particular app is started. Works, but I need to get the user who is currently logged in, and of course Environment.UserName returns the service logon (NT_AUTHORITY\SYSTEM). I understand that when the service starts, no user may be logged in, but that's ok, as the app I am monitoring can only be run by a logged in user. Do I need to use WMI to get the user context of Explorer.exe or is there a...
3
4678
by: Rahul B | last post by:
Hi, I want to grant only the connect, select, insert, update privileges on all the tables of a schema to a particular user/group Initially, i had revoked all the privileges from public. It seems that the privileges Select, Insert, Update can be given only on a table level and not on the schema level. I can iterate and get the script for the select privileges for all the tables and execute it.
7
8700
kcdoell
by: kcdoell | last post by:
Good morning everyone: I created a form and set the default view as a continuous form. Basically the form is displaying records in which the user can add or edit new ones. The record source for this form is a query that I built that is based on a table. I have been working on this for several weeks and now I have been told that many times when a user wants to create a new record, much of the information that is displayed in a...
0
9707
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10338
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10323
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9161
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6856
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5525
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5658
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3823
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2997
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.