How to set `max_prepared_stmt_count` **permanently** on mysql server?

You should add it in /etc/my.cnf on this way:

[mysqld]
max_prepared_stmt_count = 50000