The emergence of 5G has promoted the rapid development of the Internet of Things(IOT), the dramatic increasing of mobile equipment has led to the increasing shortage of spectrum resources, D2D(Device-to-Device) communication technology is widely concerned for its ability to improve the utilization of spectrum resources. In order to expand the communication scope, relay nodes are introduced into D2D communications, as the third party of D2D relay communication, the quality of relay nodes directly affects the quality of communication process. In order to make more users willing to participate in relay communication, social relationship is introduced into D2D relay communication, However, as an explicit relationship between people, the function of social relationship in D2D communication is limited by the mobility of users and the variability of communication scenarios. In order to find a more reliable relay node and upgrade the connection success rate of D2D relay communication, implicit social relationship between the users need to be mined. Aiming at that, user trust degree (UTD) is established in this paper. By combining the explicit relationship which is called the social connectivity degree with the implicit social relationship called the interest similarity degree, and considering the user’s movement, a relay selection algorithm is presented to help sender find a relay node with a deeper user trust, which can increase the user’s willingness to participate in D2D relay communication and upgrade the success rate of communication connection, so this algorithm can ensure the security of the relay node and can improve the throughput performance. Simulation results show that this algorithm can increase the success rate of connection, improve the overall throughput of the system and improve the user's communication experience.