phpMyAdmin tried to connect to the MySQL server, and the server rejected the connection XAMPP

Solution 1:

I have wasted now 2 days on this. Finaly I got the solution, remove xampp and install mysql, phpmyadmin, php5, apache2 manually.

sudo apt-get install apache2 mysql-server mysql-client php5 libapache2-mod-php5
apt-cache search php5

Then pick the ones you need and install them like this:

apt-get install php5-mysql php5-curl php5-gd php5-intl php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl
sudo apt-get install phpmyadmin
sudo service apache2 restart

Now you can open http://127.0.0.1/phpmyadmin/

These upper commands will make your xampp server. It will resolve your problem quickly and worked very smoothly.

Thanks to related articles:
1. Ubuntu 14.10 LAMP server tutorial with Apache 2, PHP 5 and MySQL (MariaDB)
2. How do I change the root directory of an apache server?