使用PHP锁定SQL服务器数据库

时间:2021-02-09 23:43:00

I'm wanting extra security for a particular point in my web app. So I want to lock the database (SQL Server 2005). Any suggestions or is this even necessary with SQL Server?

我想为我的web应用程序中的某个特定点提供额外的安全性。所以我想要锁定数据库(SQL Server 2005)。对于SQL Server有什么建议吗?

Edit on question:

编辑上的问题:

The query is failing silently with no errors messages logged, and does not occur inside of a transaction.

查询以静默方式失败,未记录任何错误消息,且不发生在事务内部。

Final Solution:

最终解决方案:

I never was able to solve the problem, however what I wound up doing was switching to MySQL and using a transactional level query here. This was not the main or even a primary reason to switch. I had been having problems with SQL Server and it allowed me to have our CMS and various other tools all running on the same database. Previous we had a SQL Server and a MySQL database running to run our site. The port was a bit on the time consuming however in the long run I feel it will work much better for the site and the business.

我从来没能解决这个问题,但是我最后做的是切换到MySQL并在这里使用事务级查询。这不是改变的主要原因,甚至不是主要原因。我在SQL Server上遇到了问题,它允许我在同一个数据库上运行我们的CMS和其他各种工具。之前我们有一个SQL服务器和一个MySQL数据库运行我们的站点。端口有点浪费时间,但是从长远来看,我觉得它对站点和业务来说会更好。

2 个解决方案

#1


6  

I suppose you have three options.

我想你有三个选择。

  1. Set user permissions so that user x can only read from the database.

    设置用户权限,以便用户x只能从数据库中读取。

  2. Set the database into single user mode so only one connection can access it

    将数据库设置为单个用户模式,因此只有一个连接可以访问它。

    sp_dboption 'myDataBaseName', single, true

    sp_dboption myDataBaseName,单身,真的

  3. Set the database to readonly

    将数据库设置为只读

    sp_dboption 'myDataBaseName', read only, true

    sp_dboption 'myDataBaseName',只读,true

#2


1  

I never was able to solve the problem, however what I wound up doing was switching to MySQL and using a transactional level query here. This was not the main or even a primary reason to switch. I had been having problems with MSSQL and it allowed me to have our CMS and various other tools all running on the same database. Previous we had a MSSQL and a MySQL database running to run our site. The port was a bit on the time consuming however in the long run I feel it will work much better for the site and the business.

我从来没能解决这个问题,但是我最后做的是切换到MySQL并在这里使用事务级查询。这不是改变的主要原因,甚至不是主要原因。我在MSSQL上遇到了问题,它允许我在同一个数据库上运行我们的CMS和其他各种工具。之前我们有一个MSSQL和一个MySQL数据库运行我们的站点。端口有点浪费时间,但是从长远来看,我觉得它对站点和业务来说会更好。

#1


6  

I suppose you have three options.

我想你有三个选择。

  1. Set user permissions so that user x can only read from the database.

    设置用户权限,以便用户x只能从数据库中读取。

  2. Set the database into single user mode so only one connection can access it

    将数据库设置为单个用户模式,因此只有一个连接可以访问它。

    sp_dboption 'myDataBaseName', single, true

    sp_dboption myDataBaseName,单身,真的

  3. Set the database to readonly

    将数据库设置为只读

    sp_dboption 'myDataBaseName', read only, true

    sp_dboption 'myDataBaseName',只读,true

#2


1  

I never was able to solve the problem, however what I wound up doing was switching to MySQL and using a transactional level query here. This was not the main or even a primary reason to switch. I had been having problems with MSSQL and it allowed me to have our CMS and various other tools all running on the same database. Previous we had a MSSQL and a MySQL database running to run our site. The port was a bit on the time consuming however in the long run I feel it will work much better for the site and the business.

我从来没能解决这个问题,但是我最后做的是切换到MySQL并在这里使用事务级查询。这不是改变的主要原因,甚至不是主要原因。我在MSSQL上遇到了问题,它允许我在同一个数据库上运行我们的CMS和其他各种工具。之前我们有一个MSSQL和一个MySQL数据库运行我们的站点。端口有点浪费时间,但是从长远来看,我觉得它对站点和业务来说会更好。