You don’t really need to exchange dollars into pesos. All establishments accept and prefer US dollars and their rates will be posted in dollars. Same goes for the vendors on the beach. Make sure to bring small bills as often they don’t have change for the larger bills.
If you prefer to pay in pesos, you can do this but it’s best not to exchange money before arriving in Mexico.
More times than not, you will get a better exchange rate in Mexico. Money can be exchanged through ATMs or at local banks. Also, if you don’t have a foreign exchange fee on your credit card you will generally get the best exchange rate when paying by credit card