创建过程时访问被拒绝(在information_schema上选择)

时间:2019-04-07 12:50:48

标签: mysql

我以root用户身份登录到mysql,然后尝试创建一个过程来清除指定数据库表中的所有数据。

为此,我尝试使用information_schema表。该过程编写如下。

DELIMITER $$

CREATE PROCEDURE `DeleteData`(IN lastDays nvarchar(3))
BEGIN
declare tbl_name varchar(100);
declare time_query nvarchar(4000);
declare done bit;

declare cur1 cursor for select TABLE_NAME from tables where TABLE_SCHEMA='LOG';
declare continue handler for not found set done=1;

    set done = 0;
     open cur1;
     igmLoop: loop
        fetch cur1 into tbl_name;
        if done = 1 then leave igmLoop; end if;
        set @time_query = 'DELETE FROM '+ @tbl_name + ';';
        PREPARE stmt1 FROM @time_query; 
        EXECUTE stmt1; 
        DEALLOCATE PREPARE stmt1; 
     end loop igmLoop;
     close cur1;
END$$
DELIMITER $$

但是我得到这个错误: 错误代码:1044。拒绝用户'root'@'%'访问数据库'information_schema'

我确定密码。

0 个答案:

没有答案