Several exception records for MySQL update

Source: Internet
Author: User

>>error code:1045. Access denied for user ' test ' @ '% ' (using Password:yes)

This problem is encountered when using MySQL's select * into outfile '/tmp/rs.txt ' from tb_name to export the results.

Although the current user has full permissions, file permissions need to be assigned separately, using the root user to execute:

Grant file on *. * to [email protected];
>>error code:1093. You can ' t specify target table ' mytable ' for update in FROM clause

When using an UPDATE or DELETE statement, a subquery that is added to the where condition is the result of the query.
The table can then be nested another layer, that is, "(SELECT * from table) TT", to obtain a temporary result set,
You can do this on the result set.

Delete from mytable where mytable.id not in (select Tt.id from (SELECT * from MyTable) TT where TT.SITEID=22);
>>error code:1175. You is using Safe update mode and you tried to update a table without a WHERE is uses a KEY column to disable safe mode , Toggle the option in Preferences, SQL Editor and reconnect.

The workaround is to turn off Safe mode:

SET sql_safe_updates = 0;

Note If you are using MySQL Workbench, you also need to configure the software preferences.
Because the default security setting for MySQL Workbench is that the table cannot be updated in bulk.
This error is prompted when the SQL statement to be executed is a batch update or delete.
Here's how to fix it:
Open the Workbench menu [edit]->[preferences ...]
Switch to the [SQL Editor] Page
Remove the checkmark before [forbid UPDATE and DELETE statements without a WHERE clause (safe updates)]
Click the [OK] button


>>mysql using the current time when inserting

The now () function returns the current datetime with ' Yyyy-mm-dd HH:MM:SS ' and can be stored directly in the DateTime field.
Curdate () returns today's date in the format ' Yyyy-mm-dd ', which can be stored directly in the Date field.
Curtime () returns the current time in the format ' HH:MM:SS ', which can be stored directly in the Date field.

INSERT into table (ID, time) VALUES (' 1 ', now ())

>>error code:1100. Table ' mytable ' is not locked with LOCK TABLES

I executed it before inserting it.

LOCK TABLES ' mytable ' WRITE;

To re-unlock:

UNLOCK TABLES;

  

Several exception records for MySQL update

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.