My MySQL database version is 5.6.35 and I use InnoDB.
I want to remove the Delete and Drop Table permissions of the user U1 from the table T1 in the db1 database.
The operating instructions are as follows:
Revoke delete,drop on db1.T1 from U1;
No error message appeared after execution.
But after execution, the user U1 can still use the DELETE command to delete the data row in the data table T1.
You can also use the DROP TABLE command to delete the data table T1.
Thanks for replying.
Related
I have a MySQL database table which has been listed twice with case sensitive name.
Both table names are pointing to same table, for example Admin and admin
When I checked information_schema it is listed as below:
mysql> SELECT TABLE_CATALOG, TABLE_NAME , TABLE_TYPE, ENGINE, CREATE_TIME
FROM information_schema.tables
where table_schema='school';
How do I clean up this mess?
Usually MySQL does not allow you to create the table with case-sensitive. It will show the error as :
ERROR 1050 (42S01): Table 'admin' already exists
But MySQL allows you to create a temp table with a existing name because they don't have the same "scope". A temporary table is visible in the session only, and it is dropped at session ending. If you have the same name, MySQL "hide" the original table until you drop your temp table.
I would suggest you to take a backup of the existing data and update the MySql version to 5.7 .
The user has INSERT and DELETE permissions but not SELECT permission. The user can write records but not read. When trying to "DELETE from my_table WHERE id=5" you get "#1143 select not allowed...". Is there a way to solve this?
Privileges
You need the DELETE privilege on a table to delete rows
from it. You need only the SELECT privilege for any columns that are
only read, such as those named in the WHERE clause.
source
Conclusion : If you use a where in the Delete you need the Select privilege too.
For a user in MySQL 5.6, can I limit the privileges to the point where the user can have delete, update privileges but
The user cannot update the whole table (no update without a where clause)
The user cannot delete the whole table (no delete without a where clause)
I am executing a query
ALTER TABLE message ADD COLUMN syncid int(10) NOT NULL DEFAULT 0;
MySQL returned error:
ERROR 1878 (HY000): Temporary file write failure.
message table info:
engine type:InnoDB
rows:15786772
index length:1006.89 MB
data length:11.25 GB
How to fix it?
MySQL implements ALTER TABLE as a table re-creation, so two copies of the table exists on the system at some stage during the process. You will need over 12 GB free space for this operation.
Free some space. Alternatively, set your server to use a different temporary directory, where there is enough space.
Alternative to the alternative (the WHILE might need to be wrapped in a stored procedure):
create a new table (temp_table) with the new structure
transfer data in small batches from original_table into temp_table
drop original_table and rename temp_table
-- useful only if concurrent access is allowed during migration
LOCK TABLES original_table WRITE, temp_table WRITE;
SELECT COUNT(*) INTO #anythingleft FROM original_table;
WHILE #anythingleft DO
-- transfer data
INSERT INTO temp_table
SELECT
original_table.old_stuff,
"new stuff"
FROM original_table
ORDER BY any_sortable_column_with_unique_constraint -- very important!
LIMIT 1000; -- batch size, adjust to your situation
DELETE FROM original_table
ORDER BY any_sortable_column_with_unique_constraint
LIMIT 1000; -- ORDER BY and LIMIT clauses MUST be exactly the same as above
SELECT COUNT(*) INTO #anythingleft FROM original_table;
END WHILE;
-- delete, rename
DROP TABLE original_table;
UNLOCK TABLES;
RENAME TABLE old_table TO original_table;
If your table uses InnoDB, a more elaborate solution is possible with SELECT ... FOR UPDATE; instead of table locks, but I trust you get the idea.
Sorry for the late answer or digging up this old topic, but the following tools can help you with that:
pt-online-schema-change
github/gh-ost
Both tools recreate the table in the fashion that #RandomSeed proposed, but in a simpler way.
However please ensure that there is enough space on the file system. Those tools don't need more space in the temporary folder, which is interesting when you're mounting your temporary folder on a separate drive / RAMdisk.
I want to log the changes history of tables in a single table
Eg:
table a(col1,col2,col3)
table b(col1,col2)
table history(tablename,olddata,newdata,modifiedDate,modifiedBy)
if i execute an update statement, for eg
update a set col1=2,col2=4,col3=5
then it should log on the history table as
a|col1=1,col2=2,col3=3| col1=2,col2=4,col3=5|13/6/2012|username