0

I'm currently working in Visual Studio 2010. MVC3 project. I'm new to .NET MVC and the only experience I have so far is with an MVC3 EF Code First project (MSSQL DB).

I'm looking to create another project and connect to a MySQL database. I can connect to the db fine but the DB credentials I am using have full access (I don't have access to any other accounts). I only want to connect read-only. (The application is a kind of reporting app). The DB is a test one but I'm afraid I'll do something stupid and either persist data back that I don't want to or I'll drop the DB altogether. (Even though it's a test DB, other people are using it)Is there a way of making my connection read-only via the connection string? Can anyone point me in the right direction?

Kindest Regards

Dubh
  • 55
  • 1
  • 10

1 Answers1

1

You have to create an account on mysql that have readonly permissions and then setup your connection string to use that account. This link should be a start

Another alternative, if you can't create a user, could be to create some views in the db and quering them. (I will not dive into the performance gain/loss)

Iridio
  • 9,213
  • 4
  • 49
  • 71
  • Unfortunately I don't have the means of creating another mysql account. I have to make do with the credentials I was given. – Dubh Apr 12 '12 at 11:50
  • @Iridio is correct, your authorization level in the DB is contained in the credentials you connect with. In order to lower the authorization level, either a new account is necessary or the account in use should be modified to lower the authorization. – CD Smith Apr 12 '12 at 11:57
  • Updated with another alternative – Iridio Apr 12 '12 at 11:57
  • Thanks for the alternative. Unfortunately I have no access to the DB at all (other than the credentials I've been given) – Dubh Apr 12 '12 at 12:11
  • I guess the only way is, like @CD Smith told, to ask your DBA to lower your privileges. Or be careful in writing your code ;) – Iridio Apr 12 '12 at 12:16
  • I was afraid that would be the answer :) Thanks for all your help guys. – Dubh Apr 12 '12 at 12:27