Problem: Too many connections error occurred and you can’t access via PHPMyAdmin or command line.
This is because no more connection can be made, so you have to stop MySQL service and change the setting.
Solution: first stop MySQL service, I user MariaDB so the service will be mariadb:
systemctl stop mariadb systemctl start mariadb
then enter MySQL prompt via MySQL, and enter below query to check current maximum connection:
SHOW VARIABLES LIKE "max_connections";
The default value is 151. You can set a higher one like
SET GLOBAL max_connections = 1000;