Multiple user creation mysql
I and some friends created a forim a long time ago. We had some users and made a list with their usernames but unfortunately our website was hijacked and lost access to the database. The question I want to know is if there is a possibility that a command on phpmyadmin exists that will create multiple users at the same time from a list.
My steps so far:
CREATE USER 'jeffrey'#'localhost' IDENTIFIED BY 'mypass';
All you have to do is :-
Insert into mybb_users SET username='some_username', email='email_of_person' , password = '098f6bcd4621d373cade4e832627b4f6', salt = '';
You can also fill other column of user table of your choice.
Related
Im currently setting up a database system with a lot of different users, having access to only limited views, and tables of the database system.
Now I need to create several triggers as the root user, to prevent some actions. But all the users should be able to create a trigger for a database created for them and the tables within. This is working fine since every user has database-specific privileges. Sadly this does allow for some reason the user to delete triggers set by the root user on their database.
If I have database 'A' with table 'test'. I create a trigger as root user for database 'A' table 'test'. Now user 'someone' has privileges to create triggers for database 'A', but he should NOT be able to remove any trigger set by the root account on database 'A'. Sadly he can remove triggers created by root... anyone know how to fix this for MySQL?
Here is the privileges for the user for the specific database:
Now the query executed by the root user:
Result in with SHOW TRIGGERS executed by user 'someone' on database 'A':
Execution of DROP TRIGGER by user 'someone' on database 'A':
Why can the user remove this trigger? It's not created by him but root... Also for anyone asking, the query 'SELECT CURRENT_USER();' returns 'someone#localhost' and NOT 'root#localhost', i have activly switched accounts.
If you grant a user the TRIGGER privilege to create triggers on a given table, you grant them all the operations that privilege covers, which includes both create and drop
https://dev.mysql.com/doc/refman/8.0/en/drop-trigger.html says:
DROP TRIGGER requires the TRIGGER privilege for the table associated with the trigger.
It doesn't matter who defined the trigger. MySQL generally has no concept of ownership for database objects like tables or triggers.
You are going to have to think of a different design that does not require users to be disallowed this access.
I have created the user on MySQL and grant SELECT access on some tables. I only want this user has SELECT access on these tables, nothing else. This is my query for creating the user and granting access:
create user 'test'#'localhost' identified by '123test';
grant select on APE.CertificationAttachment to 'test'#'localhost';
The problem is when I use this user login, I can not see anything under schema in Workbench. I try to login at other tools such as Dbeaver but the table and schema still don't show up. I tried to give schema privilege to the user, but that action will either give select access to all table or show the entire schema.
So my question is how should I do to make the users see the table and only these table that they have SELECT access to.
I have a table, lets call it student, in a schema called enrollment. Table student has a column called address that I don't want a certain user to update (other permissions are fine such as select, insert). All other columns in that table AND in that schema should have the update privilege.
Is this doable?
You can set privileges on database / table / column. But I really would not try to use MySQL's privilege mechanism at that level. I would instead write application code to decide who can see/change what. This is more flexible in the long run. And more graceful to the user -- instead of getting a cryptic MySQL error message about permissions, the UI would simply not show what should not be shown. For updating, the UI would not even give the user the option.
In my case, I wanted a specific application to be able to update only 1 field (my_field) in only 1 table (table_name) while being able to read the entire database.
I created a special user for that purpose:
CREATE USER 'restrictedUser'#'%' IDENTIFIED BY 'PASSWORD_HERE';
SET PASSWORD FOR 'restrictedUser'#'%' = PASSWORD('PASSWORD_HERE');
GRANT USAGE ON *.* TO 'restrictedUser'#'%';
GRANT SELECT ON DATABASE_NAME.* TO 'restrictedUser'#'%';
GRANT UPDATE (my_field) ON DATABASE_NAME.table_name TO 'restrictedUser'#'%';
Documentation for Column privilege can be found here for mariaDb and here for mysql
In phpmyadmin I want to grant users to create and delete databases but this access should be limited to a specific prefix.
My users have 3 different accounts on PhpMyAdmin: username_ro (for only reading), username_rw (for reading and writing) and username_admin (for creating other databases and tables into their account)
I want them to be able to create a database username_website but I don't want them to be able to create database theother_website. They should also be able to drop username_website but unable to drop theother_website
How can I do this with sql or PhpMyAdmin.
Thanks in advance.
With some trial and error I have found a solution. By doing this query I was able to create and drop database username_website but I wasn't able to create or drop database theother_clients
GRANT ALL PRIVILIGES
ON `username\_%`.*
TO 'username_admin'#'localhost';
PS. the query is a little edited. I changed the rights I actually gave with ALL PRIVILIGESand I changed the actual username with username.
I have a database role named app_user with select, update, insert and delete rights on all tables except 2. On this 2 tables app_user role has only select right.
But, some users have right to create database users (using create login, sp_adduser, sp_addrolemember). To be able to execute this procedures they must have sysadmin server role. In this case sysadmin role is over database role app_user and they can update this 2 tables. Currently, I'm giving them securityadmin role but they can execute only create login while creating db users.
To summarize,
I want to protect updating 2 tables for all users except my sysadmin account, and I want some users to be able to create database users (my app executes sp which grant db permission for that kind of users).
You might get a better answer on the DBA site, but it looks like you want to allow the users to execute 3 commands: CREATE LOGIN, CREATE USER and sp_addrolemember (because ALTER ROLE can't add members to a role in SQL Server 2008).
According to the documentation, the minimum permissions needed are:
CREATE LOGIN - ALTER (ANY) LOGIN
CREATE USER - ALTER ANY USER
sp_addrolemember - ALTER permission on the role
So they shouldn't need either sysadmin or db_owner permissions, if you grant them the permissions listed above.