Make sure to have foods high in magnesium in your diet. These foods can help you avoid future back pain. Magnesium is essential for the relaxing and contracting of your muscles. It helps preserve muscle tone and bone density, which can then help avoid back problems. Magnesium is found in bananas, nuts and seeds, whole grains and whole-grain breads, potatoes, avocados, greens like spinach and broccoli.