insert command denied in mysql

后端 未结 7 988
天涯浪人
天涯浪人 2021-01-17 07:41

I have a database table from which, when I select data with username and password, it works but when I insert some data in that table with same username and password it show

相关标签:
7条回答
  • 2021-01-17 08:07

    This is a permissions problem. Log into a MySQL prompt with the user the app is running as, and enter this query:

    SHOW GRANTS;
    

    This will show you the privileges (grants in MySQL-speak) that the current user has. My guess is that you won't see INSERT privileges for the given table. You will need the root user to grant you permission by running this query:

    GRANT INSERT ON 'db'.'tablename' TO 'username'@'localhost'
    
    0 讨论(0)
  • 2021-01-17 08:11

    In your query you might be using table name with database name "INSERT INTO DB_NAME.table_name ..." where you database user do not have insert permissions for DB_NAME. So this error is coming because query is pointing to the table of another database.

    You need to remove the database name or use correct database name either.

    0 讨论(0)
  • 2021-01-17 08:12

    Check your SQL code.

    And just delete dbName if you have.

    Example:

    insert into `dbName`.`tableName` ( columns ) values ( values );
    

    Change to:

    insert into `tableName` ( columns ) values ( values );
    
    0 讨论(0)
  • 2021-01-17 08:15

    I just had the same issue.

    Our hosted mysql provider removed the insert permission when the max db volume was reached.

    Using the

    SHOW GRANTS;
    

    command (mentioned in answer above) in mysql helped me figure this out.

    We used JAWS DB MYSQL, but other hosted mysql providers may use the same method.

    0 讨论(0)
  • 2021-01-17 08:16

    I had a similar problem after moving my site from one hosting account to another. The problem was caused by a SQL query (INSERT) that referenced the old database. replacing the old db with the new db name (or just removing the db name altogether) solved the problem. But this mistake stumped the support people at my hosting company.

    Example:

    INSERT INTO old_db_name.table_name ( ) VALUES ();
    

    Changed to:

    INSERT INTO new_db_name.table_name ( ) VALUES ( );
    

    Hope this helps and makes sense.

    0 讨论(0)
  • 2021-01-17 08:17

    This also happened to me and the problem is that when you call the command INSERT in your php file you must have specified another database.

    In short, find where your INSERT command is and check the part your_database_name below

    "INSERT INTO \`your_database_name\`.\`your_table_name\`
    

    That might solve your problem. Of course, if all privileges are granted for you.

    0 讨论(0)
提交回复
热议问题