Lost connection to MySQL server at ‘reading initial communication packet’, system error: 0 “Internal error/check (Not system error)” – MariaDB / MySQL

If you get this error when trying to connect to a remote MariaDB or MySQL server then don’t fret.

The MySQL log file doesn’t provide any help either, we had the following in ours:

[Warning] Aborted connection 4 to db: 'unconnected' user: 'unauthenticated' host: 'IP.SERVER.ADDRESS' (This connection closed normally without authentication)

The solution to the problem is very simply, you need to grant access to the IP for the user you are trying to connect from. We’ll assume our user is called db_user334.

CREATE USER 'db_user334'@'123.456.789.123' IDENTIFIED VIA mysql_native_password USING '***'; GRANT ALL PRIVILEGES ON *.* TO 'db_user334'@'123.456.789.123';

That’s it, you’re done!