9

I am trying to do a migration with Django to a MySQL database, but I am receiving this error:

(1005, "Can't create table '#sql-60_f71' (errno: 13)")

I have done several migrations before to this database and this is the first time I am seeing this error. The thing that really confuses me is that my migration isn't even creating a table. Here is what the migrations look like:

operations = [
    migrations.AddField(
        model_name='inverter',
        name='custom_name',
        field=models.CharField(blank=True, default=b'', max_length=30),
    ),
    migrations.AlterField(
        model_name='status',
        name='generic_name',
        field=models.CharField(default=b'Status', max_length=20),
    ),
]
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
keverly
  • 1,360
  • 1
  • 15
  • 21
  • 2
    (errno: 13) is a permissions error. I have no idea what's causing it from the information you've provided but some other people have talked about looking at your directories and seeing if you have the correct rights. http://stackoverflow.com/questions/2476272/mysql-error-1005-hy000-cant-create-table-tmp-errno-13 – Dresden May 12 '16 at 00:24
  • @Dresden You are right. owner of database was me rather than mysql. I just had trouble figuring out where in the directory my database was located (ended up being in /usr/local/mysql/data/) – keverly May 12 '16 at 00:42

2 Answers2

13

Found the answer here https://stackoverflow.com/a/4037158/5285571. I was having trouble because my database was not located at /var/lib/mysql. I ended up having to do sudo chown -R mysql:mysql /usr/local/mysql/data/my_database.

Community
  • 1
  • 1
keverly
  • 1,360
  • 1
  • 15
  • 21
0

I was also facing the same problem, but I figured out this one. I don't know how it worked.

But for god sake, it worked for me and I am not a professional in programming, but I am learning.

The first time I created the database using like "/var/lib/mysql then mkdir a", but it didn't work, so I created the database in MySQL instead manually at /var/lib/mysql, and then I created the table, and it worked for me.

mysql> create database a;
Query OK, 1 row affected (0.08 sec)

mysql> use a;
Database changed
mysql> create table a(Name char(21));
Query OK, 0 rows affected (0.27 sec)
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
jason
  • 135
  • 2
  • 3
  • 9