I have a script to install MySQL 5.7 and run tests on Travis CI (running Ubuntu 12).
The script contains these lines, to install MySQL in non-interactive mode, with no password:
add-apt-repository 'deb http://repo.mysql.com/apt/ubuntu/ precise mysql-5.7-dmr'
apt-get update
echo mysql-community-server mysql-community-server/root-pass password "" | debconf-set-selections
echo mysql-community-server mysql-community-server/re-root-pass password "" | debconf-set-selections
DEBIAN_FRONTEND=noninteractive apt-get -o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confold -q -y install mysql-server libmysqlclient-dev
The install runs smoothly, and using the mysql
command-line utility, I can connect to the server using no password:
mysql --user=root -e "SELECT VERSION();"
+-----------+
| VERSION() |
+-----------+
| 5.7.8-rc |
+-----------+
Now if I try to connect using PHP PDO:
new PDO('mysql:host=localhost', 'root', '');
I get the following error:
SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: NO)
I tried to allow root
to connect from any host:
GRANT ALL ON *.* to root@'%' IDENTIFIED BY '';
FLUSH PRIVILEGES;
Without success.
What can be the problem?