Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Allow an user in JawsDB to make an INSERT statement

I have a deployed app in Heroku and the DB manager is MySQL JawsDB. I would like to use Navicat to insert data for my users. The app is just for consultation. I can connect to my JawsDB DB but, when I'm trying to insert new data I get an error 1142 - INSERT command denied to user 'myJawsDBUser'@'myIPAddress' for table 'myTable'. I checked documentation and says:

If you are on one of JawsDB’s shared plans, you may have breached the database size allotted via your plan. When a database grows larger than the plan allows, INSERT privileges are revoked on the database user until the database is brought back into compliance.

After make a check of the size of my DB, I see that I have less than maximum size plan allows.I think is a problem with privileges, how can I change this if I don't have access to Users table

like image 222
Golinmarq Avatar asked Feb 01 '17 16:02

Golinmarq


1 Answers

Disclosure before answer: I'm with JawsDB :)

Jaws calculates used space by adding up the data_length and index_length values of each table in that database according to the information_schema.

A query like the one below is used to do this.

select
    s.schema_name
    ,sp.grantee user
    ,cast(round(sum(coalesce(t.data_length + t.index_length, 0)) / 1024 / 1024, 3) as char) db_size_mb
    ,sp.has_insert
from
    information_schema.schemata s
    inner join
    information_schema.tables t on s.schema_name = t.table_schema
    inner join (
        select
            spi.grantee
            ,spi.table_schema
            ,max(
                case
                    when spi.privilege_type = 'INSERT' then 1
                    else 0
                end
            ) has_insert
        from
            information_schema.schema_privileges spi
        group by
            spi.grantee
            ,spi.table_schema
    ) sp on s.schema_name = sp.table_schema
group by
    s.schema_name;

If the size of the database's tables exceeds the size granted to the user's plan, the INSERT privilege is temporarily revoked until database size is brought back into compliance with the plan. This can either be done by deleting old data or by upgrading their plan.

like image 123
johnatjawsdb Avatar answered Sep 27 '22 15:09

johnatjawsdb