MySQL is blocked because of many connection errors

More rarely, it can happen when the client is attempting the initial connection to the server. In this case, if your connect_timeout value is set to only a few seconds, you may be able to resolve the problem by increasing it to ten seconds, perhaps more if you have a very long distance or slow connection. You can determine whether you are experiencing this more uncommon cause by using SHOW STATUS LIKE ‘aborted_connections’. It will increase by one for each initial connection attempt that the server aborts. You may see “reading authorization packet” as part of the error message; if so, that also suggests that this is the solution that you need.

Try increasing connect_timeout in your my.cnf file

Another style:

MySQL: Lost connection to MySQL server at ‘reading initial communication packet’

  1. At some point, it was impossible for remote clients to connect to the MySQL server.
  2. The client (some application on a Windows platform) gave a vague description like Connection unexpectedly terminated.
  3. When remotely logging in with the MySQL client the following error appeared:
    ERROR 2013 (HY000): Lost connection to MySQL server at 'reading initial communication packet', system error: 0

On FreeBSD this happens because there was no match found in /etc/hosts.allow. Adding the following line before the line saying ALL:ALL fixes this:

mysqld: ALL: allow

On non-FreeBSD Unix systems, it is worth to check the files /etc/hosts.allow and /etc/hosts.deny. If you are restricting connections, make sure this line is in /etc/hosts.allow:

mysqld: ALL

or check if the host is listed in /etc/hosts.deny.

In Arch Linux, a similar line can be added to /etc/hosts.allow:

mysqld: ALL

Verificar se existe uma tabela tem registos para um determinado tipo

O objetivo é verificar se para um determinado ID existem registos numa tabela devolvendo true/false em vez do número de registos. Aqui ficam 2 formas de fazer isto.

Utilizando IF:

FROM itemtypes
WHERE parentid = 1

Utilizando CASE:

SELECT case when COUNT(*) > 0 
            then 1
            else 0
       end AS NewResult
FROM itemtypes
WHERE parentid = 1

Moodle infectado com ad by…

Em algumas categorias e disciplinas do Moodle apareciam DIVs com publicidade no cabeçalho e no rodapé… A publicidade estava na descrição das próprias categorias e disciplinas e foi adicionada involuntariamente por um dos admins/responsáveis porque tinha o browser infectado…

Para verificar quais as tabelas do Moodle que têm scripts, faz-se uma pesquisa na base de dados…


Se aparecer algum resultado diferente de 0, pode ser ali que estão os scripts.