This paper introduces a symbolic genetic algorithm (SGA) for discovering the partial differential equations (PDEs) capable of independently deriving PDEs directly from data, devoid of prior knowledge regarding equation structure. Primarily, SGA employs a flexible symbol representation of PDEs, transforming these into a forest with each PDEs segment forming a binary tree. Subsequently, SGA utilizes a novel algorithm to update the node attributes of the tree, and optimizes the binary tree (the terms of PDEs), obtaining the definitive form. It is worth mentioning that SGA adopts the sparse regression algorithm in error optimization and finite difference method in derivative approximation, combining the traditional numerical method with the modern method. In the experiment, SGA successfully discovered the Korteweg-de Vries (KdV) equation by two-soliton and three-soliton solutions. Likewise, two kinds of nonlinear Schr & ouml;dinger (NLS) equations were accurately discovered using a two-soliton solution and second-order rogue waves. In the future, this algorithm can not only be extended to find out some complex differential equations based on partial data of existing solutions, but also be expected to automatically match some known differential equations or even discover new differential equations from some data in physics, chemistry, biology, and other experiments, which is very meaningful.