Granting Table Permissions in TiDB is Very Slow

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: tidb按表授权,授权速度很慢

| username: Wander

The authorization in TiDB is very slow. Granting permissions at the table level, with a total of more than 30,000 grant SQL statements, the script-generated grant.sql is executed using the command mysql <grant.sql. It has been running for 16 hours and still hasn’t finished. I don’t know where to start troubleshooting this issue. Experienced friends, please advise.

| username: 我是咖啡哥 | Original post link

You can split the file and execute multiple parts simultaneously. Putting everything in one file is too slow.
split -l 100 -d -a 2 grant.sql grant.sql_
Use nohup to run it in the background.

| username: tidb菜鸟一只 | Original post link

SELECT * FROM mysql.`tables_priv`;---Check which privileges have been assigned
SELECT * FROM INFORMATION_SCHEMA.`PROCESSLIST`;---Find the privilege assignment statement and see the current status