8

I can't run my tests on Travis CI because i can't find a way to setup mysql 5.7 in container.

I've found this gist https://gist.github.com/BenMorel/d981f25ead0926a0cb6d explaining a configuration method for travis.yml. Here are the commands :

sudo apt-get remove --purge "^mysql.*"
sudo apt-get autoremove
sudo apt-get autoclean
sudo rm -rf /var/lib/mysql
sudo rm -rf /var/log/mysql
echo mysql-apt-config mysql-apt-config/enable-repo select mysql-5.7-dmr | sudo debconf-set-selections
wget http://dev.mysql.com/get/mysql-apt-config_0.2.1-1ubuntu12.04_all.deb
sudo dpkg --install mysql-apt-config_0.2.1-1ubuntu12.04_all.deb
sudo apt-get update -q
sudo apt-get install -q -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" mysql-server

right after that, I'm doing :

$ mysql -uroot < tests/ApiBundle/Datas/dump_test.sql
ERROR 1698 (28000): Access denied for user 'root'@'localhost'

Why ?? I've tried so many things… And Google is definitely not my friend for this issue…

4
  • Have you tried sudo mysql -uroot < tests/ApiBundle/Datas/dump_test.sql? Commented Jan 16, 2016 at 22:26
  • yes I did… same error ! Commented Jan 16, 2016 at 23:31
  • Have you tried using Docker? Check this: medium.com/@mtparet/… Commented Oct 26, 2017 at 19:08
  • Since the time I posted this, of course I did :), and still do every time I face the same kind of issue with CI / development / tests run. As everyone should nowadays. Still, I don't want or should update this question nor the answers IMHO as they still may be useful to anyone trying to do that out of containers. Commented Oct 27, 2017 at 20:19

2 Answers 2

8

Ok I've found out how to reinstall MySQL 5.6 in Travis CI default container.

Here is what is needed in .travis.yml:

services:
  - mysql
sudo: true
before_script:
  - bash .travis.install-mysql-5.7.sh

And here is the .travis.install-mysql-5.7.sh (edited thanks to @codyzu answer):

echo mysql-apt-config mysql-apt-config/select-server select mysql-5.7 | sudo debconf-set-selections
wget https://dev.mysql.com/get/mysql-apt-config_0.7.3-1_all.deb
sudo dpkg --install mysql-apt-config_0.7.3-1_all.deb
sudo apt-get update -q
sudo apt-get install -q -y --allow-unauthenticated -o Dpkg::Options::=--force-confnew mysql-server
sudo mysql_upgrade

I hope it would help anyone facing the same issue !

Sign up to request clarification or add additional context in comments.

5 Comments

In cases where sysem works with MySQL users (or something similar), calling sudo mysql_upgrade as the last step of .travis.install-mysql-5.7.sh is required.
This isnt working for me, im getting dependency problems: mysql-server depends on mysql-community-server (= 5.7.8-rc-1ubuntu12.04); however: Package mysql-community-server is not configured yet.
I had to add this to get it to work properly for me: sudo mysql_upgrade -u root sudo service mysql restart
This was broken because mysql-5.7-dmr no longer exists. Here is my (now) working script
I updated your answer FYI because this failed due to WARNING: The following packages cannot be authenticated! so had to pass the --allow-unauthenticated to get it to install.
1

According to the current docs, you only need to enable sudo, and add the following config in your .travis.yml file

addons:
  apt:
   sources:
    - mysql-5.7-trusty
   packages:
    - mysql-server
    - mysql-client

Source https://docs.travis-ci.com/user/database-setup/#MySQL-5.7

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.