I want to know what's the best datatype to store these:
/* the length of other numbers is always 7 digits */
/* and so on */
What you are showing are binary numbers
So simply store these numbers in an integer data type (which is internally stored with bits as shown of course). You could use BIGINT for this, as recommended in the docs for bitwise operations (http://dev.mysql.com/doc/refman/5.7/en/bit-functions.html).
Here is how to set flag n:
UPDATE mytable SET bitmask = POW(2, n-1) WHERE id = 12345;
Here is how to add a flag:
UPDATE mytable SET bitmask = bitmask | POW(2, n-1) WHERE id = 12345;
Here is how to check a flag:
SELECT * FROM mytable WHERE bitmask & POW(2, n-1)
But as mentioned in the comments: In a relational database you usually use columns and tables to show attributes and relations rather than an encoded flag list.