Privilege to select only user's own tuple only in mysqlWill this Database design logic work and what should...
How experienced do I need to be to go on a photography workshop?
Pendulum Rotation
Tikzing a circled star
How do you funnel food off a cutting board?
What is the best way to simulate grief?
Compound Interest... with Wizard Money
What formula could mimic the following curve?
How to deal with an incendiary email that was recalled
What do you call a fact that doesn't match the settings?
How to avoid being sexist when trying to employ someone to function in a very sexist environment?
What are the advantages of using `make` for small projects?
Why would the Pakistan airspace closure cancel flights not headed to Pakistan itself?
What is the etymology of the kanji 食?
Shimano Shadow vs Non-Shadow Rear Derailleur for Commuter Bike
How would an AI self awareness kill switch work?
Does the "particle exchange" operator have any validity?
Can a hotel cancel a confirmed reservation?
Why did Bush enact a completely different foreign policy to that which he espoused during the 2000 Presidential election campaign?
Can a person refuse a presidential pardon?
Called into a meeting and told we are being made redundant (laid off) and "not to share outside". Can I tell my partner?
What to do when being responsible for data protection in your lab, yet advice is ignored?
Can you earn endless XP using a Flameskull and its self-revival feature?
Can we use the stored gravitational potential energy of a building to produce power?
Unwarranted claim of higher degree of accuracy in zircon geochronology
Privilege to select only user's own tuple only in mysql
Will this Database design logic work and what should be used?(MySQL) How to change the results of a view according to the user that's viewing it?Where can I read about views for MySQL?How to organize the tables of a MySQL database with several statistics data of several years?Connecting to MYSQL on an EC2 instanceMysql (mariadb 10.1.5) update against subqueryApply the select privilege to all users in mysqlHow to grant permissions to users based on table information?SQL - Restricted view for transient (stateless) userWhat are the minimal permissions required for the “Users and Privileges” tab in MySQL Workbench to function in MySQL 5.6
I create a table named person which columns such as name, sex, occupation and so on.
I want to give each user select grant over that user’s own tuple only. I assume that each users use their own name as their user ID.
So I created view as
create view mine as select * from person where name=current_user;
And I give privilege all user
grant select on mine to public;
But it does not work.
How to grant privilege to all user in mysql?
And, in the person table, name column store only just name. But current_user replies name@localhost. So it does not match. How to solve that?
mysql
bumped to the homepage by Community♦ 11 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
I create a table named person which columns such as name, sex, occupation and so on.
I want to give each user select grant over that user’s own tuple only. I assume that each users use their own name as their user ID.
So I created view as
create view mine as select * from person where name=current_user;
And I give privilege all user
grant select on mine to public;
But it does not work.
How to grant privilege to all user in mysql?
And, in the person table, name column store only just name. But current_user replies name@localhost. So it does not match. How to solve that?
mysql
bumped to the homepage by Community♦ 11 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
yes. I mean row.
– Ju Ju
Dec 3 '15 at 15:55
add a comment |
I create a table named person which columns such as name, sex, occupation and so on.
I want to give each user select grant over that user’s own tuple only. I assume that each users use their own name as their user ID.
So I created view as
create view mine as select * from person where name=current_user;
And I give privilege all user
grant select on mine to public;
But it does not work.
How to grant privilege to all user in mysql?
And, in the person table, name column store only just name. But current_user replies name@localhost. So it does not match. How to solve that?
mysql
I create a table named person which columns such as name, sex, occupation and so on.
I want to give each user select grant over that user’s own tuple only. I assume that each users use their own name as their user ID.
So I created view as
create view mine as select * from person where name=current_user;
And I give privilege all user
grant select on mine to public;
But it does not work.
How to grant privilege to all user in mysql?
And, in the person table, name column store only just name. But current_user replies name@localhost. So it does not match. How to solve that?
mysql
mysql
edited Dec 4 '15 at 14:41
Ju Ju
asked Dec 3 '15 at 14:09
Ju JuJu Ju
4715
4715
bumped to the homepage by Community♦ 11 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
bumped to the homepage by Community♦ 11 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
yes. I mean row.
– Ju Ju
Dec 3 '15 at 15:55
add a comment |
yes. I mean row.
– Ju Ju
Dec 3 '15 at 15:55
yes. I mean row.
– Ju Ju
Dec 3 '15 at 15:55
yes. I mean row.
– Ju Ju
Dec 3 '15 at 15:55
add a comment |
2 Answers
2
active
oldest
votes
You may probably make use of LEFT
and INSTR
built in functions to strip out the host name from the user@host
.
CREATE VIEW mine
AS
SELECT * FROM person
WHERE `name`=LEFT(CURRENT_USER(),INSTR(current_user(), '@')-1);
Yes, It works. Thank you. But how to grant the access right to public? Is there a way or just I have to grant 100 persons 100 times?
– Ju Ju
Dec 4 '15 at 7:57
add a comment |
SQL does not solve all problems. And some of the problems it can solve are rather messy to code. I suggest you implement the solution to this problem in your application.
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "182"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f122795%2fprivilege-to-select-only-users-own-tuple-only-in-mysql%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You may probably make use of LEFT
and INSTR
built in functions to strip out the host name from the user@host
.
CREATE VIEW mine
AS
SELECT * FROM person
WHERE `name`=LEFT(CURRENT_USER(),INSTR(current_user(), '@')-1);
Yes, It works. Thank you. But how to grant the access right to public? Is there a way or just I have to grant 100 persons 100 times?
– Ju Ju
Dec 4 '15 at 7:57
add a comment |
You may probably make use of LEFT
and INSTR
built in functions to strip out the host name from the user@host
.
CREATE VIEW mine
AS
SELECT * FROM person
WHERE `name`=LEFT(CURRENT_USER(),INSTR(current_user(), '@')-1);
Yes, It works. Thank you. But how to grant the access right to public? Is there a way or just I have to grant 100 persons 100 times?
– Ju Ju
Dec 4 '15 at 7:57
add a comment |
You may probably make use of LEFT
and INSTR
built in functions to strip out the host name from the user@host
.
CREATE VIEW mine
AS
SELECT * FROM person
WHERE `name`=LEFT(CURRENT_USER(),INSTR(current_user(), '@')-1);
You may probably make use of LEFT
and INSTR
built in functions to strip out the host name from the user@host
.
CREATE VIEW mine
AS
SELECT * FROM person
WHERE `name`=LEFT(CURRENT_USER(),INSTR(current_user(), '@')-1);
edited Dec 4 '15 at 4:08
Erik
3,99931954
3,99931954
answered Dec 4 '15 at 3:39
JasJas
1161
1161
Yes, It works. Thank you. But how to grant the access right to public? Is there a way or just I have to grant 100 persons 100 times?
– Ju Ju
Dec 4 '15 at 7:57
add a comment |
Yes, It works. Thank you. But how to grant the access right to public? Is there a way or just I have to grant 100 persons 100 times?
– Ju Ju
Dec 4 '15 at 7:57
Yes, It works. Thank you. But how to grant the access right to public? Is there a way or just I have to grant 100 persons 100 times?
– Ju Ju
Dec 4 '15 at 7:57
Yes, It works. Thank you. But how to grant the access right to public? Is there a way or just I have to grant 100 persons 100 times?
– Ju Ju
Dec 4 '15 at 7:57
add a comment |
SQL does not solve all problems. And some of the problems it can solve are rather messy to code. I suggest you implement the solution to this problem in your application.
add a comment |
SQL does not solve all problems. And some of the problems it can solve are rather messy to code. I suggest you implement the solution to this problem in your application.
add a comment |
SQL does not solve all problems. And some of the problems it can solve are rather messy to code. I suggest you implement the solution to this problem in your application.
SQL does not solve all problems. And some of the problems it can solve are rather messy to code. I suggest you implement the solution to this problem in your application.
answered Dec 12 '15 at 6:09
Rick JamesRick James
43k22259
43k22259
add a comment |
add a comment |
Thanks for contributing an answer to Database Administrators Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f122795%2fprivilege-to-select-only-users-own-tuple-only-in-mysql%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
yes. I mean row.
– Ju Ju
Dec 3 '15 at 15:55