So, is the configuration can be made through htaccess, I mean to allow certain ip or domain to access the database?
That is not what I said. I didn't say certain domains are allowed to access the DB, I said "use the domain or IP" [of the SQL server]. Each MySQL server has an IP and if there are any domains pointing at that IP these could be used instead of the IP. Where the connection emanates from is irrelevant.
The MySQL server itself must be configured to accept incoming connections via these channels rather than just from localhost. This has nothing to do with .htaccess which is pure a configuration file for Apache webservers.