A method for automatically adjusting the hardness of a mattress based on an operator's lying position or an operator's side lying position and a device are disclosed. The device comprises: a base, having hollow platforms that have support legs; a lifting device, below the hollow platforms; a mattress body, disposed on the base and comprising a bed surface, a bed bottom, flexible support units, and gravity sensors, through holes being disposed in the bed bottom and corresponding to the lifting device, the flexible support unit being constructed by a first flexible member female-connected with a second flexible member; and a control device, connected with the lifting device and the gravity sensors, wherein the control device determines that the touching number of the gravity sensors is greater, equal to or less than a preset value and therefore automatically adjusts the hardness of the mattress.