XAMPP brings it´s own copy of MySQL. Installing the official package only means you now have two MySQL servers instances installed.
So what can happen, depending on configurations is:
- one of the instances of MySQL is not starting/not configured correctly/not with full setup completed;
- OR both are running, and you won't be able to talk with one of them;
- OR you are talking with the wrong instance without realising it.
For now, I do recommend deleting the official package and restarting the MySQL from XAMPP as a quick fix.
As recommendations for a near future:
There are several choices for a PHP framework installation, and two choices concerning this particular question:
- using the official distribution packages of Apache, MariaDB/MySQL, PHP and Perl;
- installing XAMPP.
I recommend the former approach, of using the official packages of the distribution instead of XAMPP for the following reasons:
- it is more standard (even for asking help here);
- the file locations are more standard;
- it is supported by the distribution;
- it also benefits from more regular security updates of the OS;
- on top of that it also gives less problems when upgrading either the MySQL version or the distribution version.
IMO XAMPP is better suited for people running Windows, for people running Linux it is more difficult to maintain updated and is not standard.