ARTICLE DETAIL

建站实战干货

来自一线的建站与推广经验沉淀,每一条都经过真实交付验证。

MYSQL账号和权限配置

2026/9/16 10:35:30 拓冰建站 浏览量
MYSQL账号和权限配置

新增用户并回收root用户的权限

flush privileges;
grant all privileges on *.* to 'root'@'%' identified by 'Test2024' with grant option;
grant all privileges on *.* to 'magic'@'%' identified by 'Test2024' with grant option;
flush privileges;
select user,host from mysql.user;
revoke all on *.* from 'root'@'%';
show grants for 'root'@'%';
show grants for 'magic'@'%';

修改视图的DEFINER:

SELECT
    concat(
        "alter DEFINER = 'magic'@'%' SQL SECURITY DEFINER VIEW ",
        TABLE_SCHEMA,
        ".",
        TABLE_NAME,
        " as ",
        VIEW_DEFINITION,
        ";"
    )
FROM
    information_schema.VIEWS
WHERE
    DEFINER = 'skip-grants user@skip-grants host';

注释掉mysql的配置:vim /etc/my.cnf

[mysqld]
#skip-grant-tables

修改程序的配置:vi /etc/LSMainFrameDB.INI