I. Bajo and S. Benayadi already gave a complete answer for your question in their paper entitled "[Lie algebras admitting a unique quadratic structure](https://doi.org/10.1080/00927879708826023)" in 1997, there you can find much more detail.