postgresql 设置只读用户 ` CREATE USER readonly WITH ENCRYPTED PASSWORD 'ropass'; alter user readonly set default_transaction_read_only=on; GRANT USAGE ON SCHEMA public to readonly; ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO readonl
MySQL设置了主从复制,为保证数据一致性需要在从库设置只读状态 查看默认读写状态 show global variables like "%read_only%"; 设置只读 #设置只读(一个是普通用户设置只读一个是超级用户设置只读) set global read_only=1; set global super_read_only=1; 创建一个库查看是否设置成功 提示无法创建 主从复制不受影响,可正常写入 如果在做数据恢复的时候希望从库也无法进行任何写入需要锁表 #锁表 flu
ALTER AVAILABILITY GROUP [sqlmaxiangqianbd] MODIFY REPLICA ON N'maxiangqian1' WITH (SECONDARY_ROLE (ALLOW_CONNECTIONS = READ_ONLY)); ALTER AVAILABILITY GROUP [sqlmaxiangqianbd] MODIFY REPLICA ON N'maxiangqian1' WITH (SECONDARY_ROLE (READ_ONLY_R