What I want to do is, read data "some words" dynamically from a database using MySQL and display it on screen. I want to know if this is possible in Adobe After Effects? And how do I connect if possible? Do I have to write a script where it can be written?
It's definitely possible. You would need to use Sockets to communicate via ExtendScript. You can also use something like Templater from Dataclay to easily handle this, but you would need to create a small server that you point Templater to rather than a direct connection to the database. See this support article for more information on how Templater communicates to an endpoint exposed by an API that you implement.