Django cannot properly destroy and create test databases

When I try to run my unittest, this is what I get:

python manage.py test dbank --settings=databank_web.settings.dqs.dev_hooman
Creating test database for alias 'default'...
Creating test database for alias 'global'...
Creating test database for alias 'optin_db'...
Creating test database for alias 'vpd3'...
Creating test database for alias 'user_db'...
Creating test database for alias 'vpd1'...
Creating test database for alias 'vpd2'...
.
----------------------------------------------------------------------
Ran 1 test in 0.327s

OK
Destroying test database for alias 'default'...
Warning: Table 'mysql.proc' doesn't exist

      

He was unable to destroy the database. This improves when I re-run the test:

python manage.py test dbank --settings=databank_web.settings.dqs.dev_hooman
Creating test database for alias 'default'...
Creating test database for alias 'global'...
Got an error creating the test database: (1007, "Can't create database 'test_dqs12_full2'; database exists")
Type 'yes' if you would like to try deleting the test database 'test_dqs12_full2', or 'no' to cancel: yes
Destroying old test database 'global'...
Got an error recreating the test database: Table 'mysql.proc' doesn't exist

      

Any idea why this is going wrong?

Running latest homebrew + mysql-5.6.21 + Django 1.5.5

+3


source to share


2 answers


I finally found the reason.

Our application has about 7 databases. When I was about to dump them manually to get a clean state, I accidentally dumped the database as well mysql

. This database should never be deleted because it contains important information about the root user.

When I figured it out, I tried to mitigate by reinstalling MySQL via brew.

brew uninstall mysql
brew install mysql

      



It worked and the base mysql

appeared again when I ran show databases;

, however the problem persisted. That's when I came here for help.

Things seem to be a little more complicated than when using brew. This is how I got it working again:

1) brew uninstall mysql
2) sudo rm -r /usr/local/var/mysql/
3) brew install mysql
4) unset TMPDIR
5) mysql_install_db --verbose --user='whoami' --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp
6) mysql.server restart
7) mysql_secure_installation

      

It works now. Hope this helps other Mac users. Thank.

0


source


Well, there are two errors indicating the missing table mysql.proc

. You might be able to generate it with mysql_update

.



-1


source







All Articles