Federated learning is a model-level aggregation learning paradigm, which can generate high quality models without collecting the local private data of users. As a distributed coordination learning method, it can be deployed at the edge devices in mobile edge computing (MEC) systems, and provides an applicable solution of implementing network edge intelligence. However, the performance of federated learning cannot be guaranteed in the MEC systems, since the quality of local training data and wireless channels is not always satisfactory. To tackle with this problem, the joint optimization of data sampling and user selection is studied in this paper. First, to capture the key features of deploying federated learning in the MEC systems, we formulate an optimization problem to minimize the accuracy loss and cost, considering the computation and communication resource constraints. Then, an optimization algorithm is designed to jointly optimize the data sampling and user selection strategies, which can approach the stationary optimal solution efficiently. Finally, the numerical simulation and experiment results are provided to evaluate the performance of our proposed optimization scheme, which show that our proposed algorithm can significantly improve the performance of federated learning in the MEC systems.