What the best Configurationfor mysql using 4GB
Terrible:  innodb_buffer_pool_size = 4G and 4GB of RAM.  You must not over-allocate RAM; performance suffers terribly.  Change that to 1500M.  (Even 80% is dangerously high for a mere 4GB of RAM.)

key_buffer_size = 256M -- If you are not using MyISAM tables, change this to 20M.

table_open_cache = 5000 -- If you don't have thousands of tables, change this to, say, 1500.

Yes 45GB of data will work with only 1.5G of buffer_pool.  But it may be slow.  Let's see some of the slow queries.  The solution may be as simple as adding a 'composite' index to help a query.

In general, one should not modify my.cnf settings other than the buffer_pool.  Raising values, in any cases, hurts performance.