The code is absolutely ok of course. Please undo all changes that you made to the code.
Back to your original problem, by copying back the databases you have overwritten the password of the ispconfig user. This password has to be corrected in the mysql database and not the ispconfig files. Did you make a backup of the mysql.mysql database which conatins the users on the new system before youve obvewritten the db with the old database? If yes, then take this backup and get the password lines for the ispconfig users from it from all tables that are in the database and add them to the current mysql user database.