步骤 登录 mysql -u root -p 创建用户 CREATE USER '$user'@'%' IDENTIFIED BY '$password'; 分配只读权限 GRANT SELECT, SHOW VIEW ON $database_name.* TO '$user'@'%'; 刷新权限 FLUSH PRIVILEGES; 参考: How to create a read-only MySQL user?