A random access method, applied to a terminal device, the method comprising: initiating second random access operation after first random access operation fails, where first uplink data in the first random access operation and second uplink data in the second random access operation are the same in data size, the first uplink data is uplink data corresponding to a first resource for the first random access operation, the second uplink data is uplink data corresponding to a second resource for the first random access operation, the first random access operation comprises two-step random access operation or four-step random access operation, and the second random access operation comprises two-step random access operation or four-step random access operation; wherein the uplink data is a payload carried by the PUSCH, or an uplink grant; wherein the initiating second random access operation comprises: selecting a target physical random access channel, PRACH, preamble set based on configuration information and the data size of the first uplink data; and initiating the second random access operation by using the second resource; wherein the second resource comprises at least one of the following: a target third resource, and a random access uplink data shared channel resource PUSCH; and the target third resource comprises at least one of the following: a PRACH preamble and a random access occasion, RO; wherein the configuration information comprises at least one of the following: a correspondence between M PRACH preamble sets and N third resources, and a correspondence between the N third resources and X PUSCHs. initiating second random access operation after first random access operation fails, where first uplink data in the first random access operation and second uplink data in the second random access operation are the same in data size, the first uplink data is uplink data corresponding to a first resource for the first random access operation, the second uplink data is uplink data corresponding to a second resource for the first random access operation, the first random access operation comprises two-step random access operation or four-step random access operation, and the second random access operation comprises two-step random access operation or four-step random access operation; wherein the uplink data is a payload carried by the PUSCH, or an uplink grant; wherein the initiating second random access operation comprises: selecting a target physical random access channel, PRACH, preamble set based on configuration information and the data size of the first uplink data; and initiating the second random access operation by using the second resource; wherein the second resource comprises at least one of the following: a target third resource, and a random access uplink data shared channel resource PUSCH; and the target third resource comprises at least one of the following: a PRACH preamble and a random access occasion, RO; wherein the configuration information comprises at least one of the following: a correspondence between M PRACH preamble sets and N third resources, and a correspondence between the N third resources and X PUSCHs. selecting a target physical random access channel, PRACH, preamble set based on configuration information and the data size of the first uplink data; and initiating the second random access operation by using the second resource; wherein the second resource comprises at least one of the following: a target third resource, and a random access uplink data shared channel resource PUSCH; and the target third resource comprises at least one of the following: a PRACH preamble and a random access occasion, RO; wherein the configuration information comprises at least one of the following: a correspondence between M PRACH preamble sets and N third resources, and a correspondence between the N third resources and X PUSCHs.