I have been trying to access the remote MySql database server in C# Entity framework but end in following error
{"Access denied for user 'test'#'%' to database 'test'"}
My connection string is server='192.168.0.1';uid=test;database=test;password=1234
However if i access the database through workbench it allows me to access the server and inserting and deleting the data in tables.
What causing the error ?
Execute below statement to grant access on test-
GRANT all privileges on test.* to test#'%' identified by '1234';
Note: You can change all privileges with your specific permissions.
You can also assign rights on all databases by-
GRANT all privileges on *.* to test#'%' identified by '1234';
Note: Best way is that rights should provide only to specific ip and limited rights as per requirement.
Related
I am trying to use the SqlTableDependency class in my C# .Net application and I am unable to grant myself the required database permissions needed. Specifically, I need permissions:
ALTER
CONTROL
CREATE CONTRACT
CREATE MESSAGE TYPE
CREATE PROCEDURE
CREATE QUEUE
CREATE SERVICE
EXECUTE
SELECT
SUBSCRIBE QUERY NOTIFICATIONS
VIEW DATABASE STATE
VIEW DEFINITION
CONNECT
The error message states:
"An unhandled exception of type
'TableDependency.SqlClient.Exceptions.UserWithNoPermissionException'
occurred in TableDependency.SqlClient.dll. Additional information:
User with no CREATE MESSAGE TYPE permission"
I have tried granting myself the permission using this query:
GRANT CREATE MESSAGE TYPE TO dbo
but I get this error:
"Cannot grant, deny, or revoke permissions to sa, dbo, entity owner,
information_schema, sys, or yourself."
I have confirmed that dbo is the owner of my database.
I am running Sql Server 2008 R2.
How can I grant myself permissions to my server?
Whatever credentials you used in your connection string needs to be db_owner of database. I made that user as db_owner and it worked for me.
Make sure to do this:
Enable broker
ALTER DATABASE Your_db_name SET ENABLE_BROKER WITH ROLLBACK IMMEDIATE;
Go
Add to db_owner
ALTER ROLE db_owner ADD MEMBER Your_user_db_name
GO
Set authorization
ALTER AUTHORIZATION ON DATABASE::Your_db_name TO Your_user_db_name;
I hope this help.
My problem too.
When downgrade SqlTableDependency verson from 4.6.7.8 to 4.6.7, my code is running well :)
Hi guys I'm trying to connect to a MSSQL database with ASP.net! I've created a Database containing 3 tables, but every time I try and connect to the database I receive an error message stating I must obtain permission first... How do I connect or get the permission?
Windows Authentication
error
you do not have permission to open this file
contact the file owner or an administrator to obtain permission
You can adjust your string connection with IntegratedSecurity = true
Link : http://msdn.microsoft.com/fr-fr/library/system.data.sqlclient.sqlconnectionstringbuilder.integratedsecurity.aspx
Nota : information current Windows account credentials are used for authentication
Nota : you can also use server account (false), but you must specify in your string connection
Another link about build string connection : http://www.connectionstrings.com/sql-server-2012
Try something different such as enabling "SQL Server and Windows Authentication mode" in SQL Management Studio
Right click the Server node => Properties => Security
Then create a new SQL user profile with full permissions to your database and use those credentials in you connection string.
You Application Pool Identity must have enough permission to access your db.
EDIT: I reinstalled MySQL and this fixed itself. No idea what the issue was.
I ran the following commands in MySQL from the command line:
1. REVOKE ALL PRIVILEGES ON MyDB.* FROM user#'%';
2. DROP USER user#'%";
3. GRANT INSERT,SELECT,DELETE,UPDATE ON MyDB.* TO user#'%' IDENTIFIED BY 'somepassword';
4. FLUSH PRIVILEGES;
The grants for the user are:
GRANT USAGE ON . to 'user'#'%' IDENTIFIED BY PASSWORD
GRANT SELECT,INSERT,UPDATE,DELETE ON 'MyDB'.* TO 'user'#'%'
But then I get the following error message when I try to do an update.
UPDATE command denied to user 'user'#'somehost' for table 'sometable'
Relevant info:
SELECT,INSERT, and DELETE all work properly.
I am using C# with Connector/NET
'somehost' is on the same network as the server (different computer).
'sometable' is in MyDB.
If I log in to the server with 'user' on the host machine, update queries work just fine.
EDIT:
If I grant UPDATE,SELECT,INSERT,DELETE to user#'somehost.net', UPDATE queries work without a problem.
Any ideas?
After taking away all the grants, first you should give the usage privilege to the user.
GRANT USAGE on MyDB.* to 'user'#'localhost'
Usage privilege tells the server that this user is allowed to use MySQL
Reinstalling fixed the issue. Not sure what the problem was.
While i am deploying my solution in to sharepoint, it is showing:
"Inner exception(1): The EXECUTE
permission was denied on the object
'proc_putObject', database
'SharePoint_Config', schema 'dbo'".
Unable to deploy the solution.
Can any one give the solution....
Thank you.
To deploy an SharePoint solution (wsp) write access to the SharePoint Config database is required. You have to ensure that the executing user is a Farm Administrator.
I do not recommend changing the permissions on the DB manually as suggested by "System.Exception" since this is not supported by Microsoft.
As Share point uses the SQL Server as backend, I added my login id with admin permissions in SQL server. It is working fine.
Try to activate the feature using the stsadm command
stsadm -o activatefeature -name thisfeaturename> -url http://thisserver/
The login you are using to execute the sproc proc_putObject doesn't has permission to execute the sproc! For your login grant execute permission on this sproc!
I created a login to connect to SQL SERVER.
create login bobLogin with password = 'bobpass' , default_database = bobDB
but when i am connecting sql server using this, it does not connects? because it needs a user.
so i created a user:
create user bobDB_USER for login bobLogin
then i connected to sql server using bobLogin & tried to create table:
create table bobDbTable(eid int)
which gives permission denied error;
so i granted permission:
GRANT CREATE TABLE TO bobDB_USER
then i again connected using bobLogin, & tried to create a table but it gave error:
The specified schema name "dbo" either does not exist or you do not have permission to use it.
why so? its creating the table in the dbo schema, thats why? so how do i grant him this permission ?
i dont want to create a new schema. is it necessary?
You would need to GRANT ALTER ON SCHEMA::dbo TO bobDB_USER to allow objects to be created in the dbo schema.
I would also use a Role too.
create role bobDB_ROLE
EXEC sp_addrolemember 'bobDB_ROLE', 'bobDB_USER'
GRANT ALTER ON SCHEMA::dbo TO bobDB_ROLE
However, you could addbobDB_USER into db_owner if it requires these rights
EXEC sp_addrolemember 'db_owner', 'bobDB_USER'
Note: end user permissions are quite different to admin type rights. If 'bobDB_USER' is an end user, then they should not be creating objects