There is a post in Microsoft Technet that explains how we can change the database connection in the AOS Configuration (Microsoft Dynamics AX 2012 Server Configuration tool).
http://technet.microsoft.com/en-us/library/aa569613.aspx

However, once I did that I found that my AOS services couldn’t start (the AOS Service status was ‘Starting’ but he never did it and I had to restart the server to stop it).
I found the following error message checking the Event Log of the AOS server:

AX2012_EventLogAOsErrorStarting_thumb_6015ADD5

[Microsoft][SQL Server Native Client 10.0][SQL Server]The EXECUTE permission was denied on the object ‘XU_GetSchemaVersion’, database ‘myAX2012DB’, schema ‘dbo’.. The SQL statement was: “{ ? = CALL [dbo].[XU_GetSchemaVersion](?, ?) }”

 

The “Troubleshoot problems operating the Application Object Server” Microsoft Technet post didn’t solve my problem:

http://technet.microsoft.com/en-us/library/aa548675(v=ax.50).aspx

 

Searching on the Internet I found another one that finally solved my problem:

http://mathdax.blogspot.com.es/2011/04/dynamics-ax-2012-execute-permission-was.html (in French)

This post explains that the problem is fixed after executing the command:

USE [myAX2012DB]
GO
GRANT EXECUTE TO [domainaosserviceaccount]
GO

Please, note that this command can be quite dangerous: it allows to execute each of the existing procedures and also the future procedures that can be added to the database.

In our case, it shouldn’t cause problems because AOS must be able to run any query that it can get.

Thanks to my colleague Rubén Garrigós, who explained me what the SQL Sentence does exactly and warned me about its potential damage.

Cheers!