473,378 Members | 1,527 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

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 9886
"usaims" <us****@yahoo.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.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.SomeTable TO "$1"
GRANT SELECT ON SomeOtherDB.SomeOtherTable TO "$1"
USER_PERMIT


Jul 23 '05 #2
"usaims" <us****@yahoo.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.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.SomeTable TO "$1"
GRANT SELECT ON SomeOtherDB.SomeOtherTable 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
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...
2
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...
1
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...
2
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...
2
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...
7
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...
33
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...
3
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...
7
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.