SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Converting MySQL Steps to SQL Server


Converting MySQL Steps to SQL Server

Author
Message
vuser
vuser
Forum Newbie
Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)

Group: General Forum Members
Points: 2 Visits: 12
I am installing a product which needs a database - it can use any database as long as there is a jdbc connector available for it. However, the installation guide has instructions only on how to make it work with MySQL.

I am running it with SQL Server Express.

These are the instructions for MySQL

CREATE DATABASE proddb;
CREATE USER 'proddb'@'%' IDENTIFIED BY 'thepassword';
CREATE USER 'proddb'@'localhost' IDENTIFIED BY 'thepassword';
USE proddb;
GRANT ALL PRIVILEGES ON *.* TO 'proddb'@'localhost' IDENTIFIED BY 'thepassword';
GRANT ALL PRIVILEGES ON *.* TO 'proddb'@'%' IDENTIFIED BY 'thepassword';
FLUSH PRIVILEGES;

The CREATE DATABASE statement works fine on SQL Server.

However, the next statement chokes. It seems like the db name shouldn't be in quotes in SQL Server. However, I am not sure what is the equivalent for '%' in SQL Server. Likewise for 'proddb'@'localhost'.

SQL Server also chokes on *.* in the GRANT statement.

Can someone help me convert all these statements to the equivalent statements for SQL Server?
Orlando Colamatteo
Orlando Colamatteo
SSC-Dedicated
SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)

Group: General Forum Members
Points: 38644 Visits: 14411
vuser (1/21/2013)
I am installing a product which needs a database - it can use any database as long as there is a jdbc connector available for it. However, the installation guide has instructions only on how to make it work with MySQL.

I am running it with SQL Server Express.

These are the instructions for MySQL

CREATE DATABASE proddb;
CREATE USER 'proddb'@'%' IDENTIFIED BY 'thepassword';
CREATE USER 'proddb'@'localhost' IDENTIFIED BY 'thepassword';
USE proddb;
GRANT ALL PRIVILEGES ON *.* TO 'proddb'@'localhost' IDENTIFIED BY 'thepassword';
GRANT ALL PRIVILEGES ON *.* TO 'proddb'@'%' IDENTIFIED BY 'thepassword';
FLUSH PRIVILEGES;

The CREATE DATABASE statement works fine on SQL Server.

However, the next statement chokes. It seems like the db name shouldn't be in quotes in SQL Server. However, I am not sure what is the equivalent for '%' in SQL Server. Likewise for 'proddb'@'localhost'.

SQL Server also chokes on *.* in the GRANT statement.

Can someone help me convert all these statements to the equivalent statements for SQL Server?

MySQL requires you provide not only a username (e.g. proddb) but also the source IP address (or mask) it can connect from. SQL Server security does not care about source IP. If you need IP restrictions for logins you must implement your own mechanism within a LOGIN TRIGGER. Another difference is that SQL Server has Server Logins and Database Users where MySQL only has Users.

This in MySQL:

CREATE USER 'proddb'@'%' IDENTIFIED BY 'thepassword';


Would be this in SQL Server:

USE master;
CREATE LOGIN proddb WITH PASSWORD = 'thepassword', DEFAULT_DATABASE = [thedatabasename];
USE thedatabasename;
CREATE USER [proddb] FROM LOGIN [proddb]; -- here the username can be different from the login name, your choice



__________________________________________________________________________________________________
There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search