MySQL error 1449: The user specified as a definer

2019-01-04 15:47发布

When I run the following query I get an error:

SELECT
  `a`.`sl_id`                     AS `sl_id`,
  `a`.`quote_id`                  AS `quote_id`,
  `a`.`sl_date`                   AS `sl_date`,
  `a`.`sl_type`                   AS `sl_type`,
  `a`.`sl_status`                 AS `sl_status`,
  `b`.`client_id`                 AS `client_id`,
  `b`.`business`                  AS `business`,
  `b`.`affaire_type`              AS `affaire_type`,
  `b`.`quotation_date`            AS `quotation_date`,
  `b`.`total_sale_price_with_tax` AS `total_sale_price_with_tax`,
  `b`.`STATUS`                    AS `status`,
  `b`.`customer_name`             AS `customer_name`
FROM `tbl_supplier_list` `a`
  LEFT JOIN `view_quotes` `b`
    ON (`b`.`quote_id` = `a`.`quote_id`)
LIMIT 0, 30

The error message is:

#1449 - The user specified as a definer ('web2vi'@'%') does not exist

Why am I getting that error? How do I fix it?

30条回答
我想做一个坏孩纸
2楼-- · 2019-01-04 16:18

In my case, the table had a trigger with a DEFINER user that didn't exist.

查看更多
Root(大扎)
3楼-- · 2019-01-04 16:18

From MySQL reference of CREATE VIEW:

The DEFINER and SQL SECURITY clauses specify the security context to be used when checking access privileges at view invocation time.

This user must exist and is always better to use 'localhost' as hostname. So I think that if you check that the user exists and change it to 'localhost' on create view you won't have this error.

查看更多
淡お忘
4楼-- · 2019-01-04 16:19

This happened to me after I imported a dump on Windows 10 with MYSQL Workbench 6.3 Community, with "root@% does not exist". Even though the user existed. First I tried to comment out the DEFINER however, this did not work. I then did a string replace on "root@%" with "root@localhost" and reimported the dump. This did the trick for me.

查看更多
Anthone
5楼-- · 2019-01-04 16:20

If the user exists, then:

mysql> flush privileges;
查看更多
狗以群分
6楼-- · 2019-01-04 16:20

Create the deleted user like this :

mysql> create user 'web2vi';

or

mysql> create user 'web2vi'@'%';
查看更多
地球回转人心会变
7楼-- · 2019-01-04 16:20

The user 'web2vi' does not exist on your mysql server.

See http://dev.mysql.com/doc/refman/5.1/en/error-messages-server.html#error_er_no_such_user

If that user does exist, check what servers it can access from, although I would have thought that would be a different error (EG you might have web2vi@localhost, but you are accessing the db as web2vi@% (At anything)

查看更多
登录 后发表回答