How to recognize and remove malicious code on wordpress? [closed]

What this code can do actually in WordPress?

This code allows arbitrary execution of PHP on your server.

Deleting the file is enough to remove the problem?

You’ll need to delete all files that contain backdoor like this. Look at every file on your system and compare it to the WordPress repository.

In the last days, the website went down several times with mysql running out of memory. Could be this the cause?

Yes. It’s likely that some bad guy is using your server for nefarious deeds.