With the increasing demands of social services, Unmanned Aerial Vehicles (UAVs)-assisted networks promote promising prospect for improving social services. The sensing data can be collected by UAVs, a large number of applications based on UAVs can be realized in 5G networks. However, the malicious UAVs may provide false information and destroy services. The 5G UAV communication systems face the security threats. Therefore, this paper develops a novel trust-based security scheme for 5G UAV communication systems. The architecture of 5G UAV communication system is first presented to improve the communication performance. Second, a trust evaluation scheme for UAVs is developed to evaluate the reliability of UAVs. By introducing the trust threshold, the malicious UAVs will be filtered out from the systems. Third, with the assistance of mobile edge computing (MEC) nodes, the detection scheme based on Q-learning technology is proposed to detect the malicious attacks. The security threats can be detected to protect the security of systems. Finally, simulation results demonstrate the effectiveness of the proposed scheme.