A massive multiple‐input multiple‐output (MIMO) system uses a large number of antennas in the base station (BS) to serve multiple users, which significantly improves the capacity of the system. However, in time division duplex (TDD) mode, the pilot contamination (PC) is inevitable due to the multiplexing of pilots. This paper proposed a pilot assignment based on graph coloring and location information (GC‐LI) to improve the performance of users. Specifically, based on graph coloring, the proposed GC‐LI algorithm combines location information like the angle of arrival (AoA), distance, and correlation to construct an interference graph. Then, we calculate the interference between any two users and use the postprocessing discrete Fourier transform (DFT) filtering process to effectively distinguish the users with nonoverlapping AoAs. Finally, according to the interference graph, the GC‐LI algorithm is proposed to mitigate the intercell interference (ICI) between users with the same pilot by assigning different pilots to connected users with high ICI metrics based on some regulation. Simulation results show that the GC‐LI algorithm is suitable for various types of cells. In addition, compared with the existing pilot assignment algorithms based on graph coloring, users’ average signal‐to‐interference‐plus‐noise ratio (SINR) and uplink achievable sum rate (ASR) are significantly improved.