<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>MSSql Archives : vedmant.com : coding blog</title>
	<atom:link href="https://vedmant.com/tag/mssql/feed/" rel="self" type="application/rss+xml" />
	<link>https://vedmant.com/tag/mssql/</link>
	<description>Sharing my personal experience in web development</description>
	<lastBuildDate>Thu, 31 Aug 2017 13:50:21 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8</generator>
	<item>
		<title>MS SQL on Vagrant Ubuntu Homestead box for development on Laravel</title>
		<link>https://vedmant.com/ms-sql-vagrant-ubuntu-homestead-box-development-laravel/</link>
					<comments>https://vedmant.com/ms-sql-vagrant-ubuntu-homestead-box-development-laravel/#comments</comments>
		
		<dc:creator><![CDATA[vedmant]]></dc:creator>
		<pubDate>Thu, 02 Feb 2017 12:57:43 +0000</pubDate>
				<category><![CDATA[Laravel]]></category>
		<category><![CDATA[MSSql]]></category>
		<category><![CDATA[SqlSrv]]></category>
		<guid isPermaLink="false">https://vedmant.com/?p=135</guid>

					<description><![CDATA[<p>Hi everyone! Recently I had a chance to setup and successfully run development environment with Microsoft SQL Server on Laravel&#8217;s Homestead Vagrant box. I used Homestead installation per project. And here is how I&#8217;ve done it. Prepare Homestead box First step is to install Homestead for a project: Then you need to change Homestead.yaml file. &#8230; <a href="https://vedmant.com/ms-sql-vagrant-ubuntu-homestead-box-development-laravel/" class="more-link">Continue reading <span class="screen-reader-text">MS SQL on Vagrant Ubuntu Homestead box for development on Laravel</span></a></p>
<p>The post <a href="https://vedmant.com/ms-sql-vagrant-ubuntu-homestead-box-development-laravel/">MS SQL on Vagrant Ubuntu Homestead box for development on Laravel</a> appeared first on <a href="https://vedmant.com">vedmant.com :: coding blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Hi everyone!</p>
<p>Recently I had a chance to setup and successfully run development environment with Microsoft SQL Server on Laravel&#8217;s Homestead Vagrant box. I used Homestead installation per project. And here is how I&#8217;ve done it.</p>
<h3>Prepare Homestead box</h3>
<p>First step is to install Homestead for a project:</p>
<pre class="brush: bash; title: ; notranslate">
composer require laravel/homestead --dev
php vendor/bin/homestead make
</pre>
<p>Then you need to change Homestead.yaml file.</p>
<p>Firstly, memory limit have to be changed to 4096: <code>memory: 4096</code></p>
<p>Then hostname: <code>hostname: mysite.dev</code></p>
<p>And probably name for convenience: &#8216;name: mysite.dev&#8217;</p>
<p>In <code>sites</code> section make sure that you have configuration like this:</p>
<pre class="brush: yaml; title: ; notranslate">
sites:
    - map: mysite.dev
      to: &quot;/home/vagrant/project/public&quot;
</pre>
<p>Then download and install Vagrant box</p>
<pre class="brush: plain; title: ; notranslate">
vagrant up
</pre>
<p>And add to hosts file domain for a this box <code>192.168.10.10 mysite.dev</code>.</p>
<h3>Install, setup and import database</h3>
<p>To setup database login to Vagrant box</p>
<pre class="brush: bash; title: ; notranslate">
vagrant ssh
</pre>
<p>Install MS SQL server and tools:</p>
<pre class="brush: bash; title: ; notranslate">
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
curl https://packages.microsoft.com/config/ubuntu/16.04/mssql-server.list | sudo tee /etc/apt/sources.list.d/mssql-server.list
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list | sudo tee /etc/apt/sources.list.d/msprod.list

sudo apt-get update
sudo apt-get install -y mssql-server
sudo apt-get install -y mssql-tools unixodbc-dev

sudo ln -sfn /opt/mssql-tools/bin/sqlcmd-13.0.1.0 /usr/bin/sqlcmd
sudo ln -sfn /opt/mssql-tools/bin/bcp-13.0.1.0 /usr/bin/bcp
</pre>
<p>Then run initial MS SQL setup script</p>
<pre class="brush: bash; title: ; notranslate">
sudo /opt/mssql/bin/mssql-conf setup
</pre>
<p>Use password &#8220;Secret123&#8221;, start server and enable starting on boot</p>
<p>Then it will require to install Sybase php extension</p>
<pre class="brush: bash; title: ; notranslate">
sudo apt-get install -y php7.1-sybase
</pre>
<p>When it will be updating some packages, select to keep the local version of config files on prompts.</p>
<p>To connect your Laravel application to MS SQL server you may need to add following configuration to your <code>config/database.php</code> file to <code>connections</code> section:</p>
<pre class="brush: php; title: ; notranslate">
'sqlsrv' =&gt; &#x5B;
    'driver' =&gt; 'sqlsrv',
    'host' =&gt; env('DB_HOST', 'localhost'),
    'database' =&gt; env('DB_DATABASE', 'forge'),
    'username' =&gt; env('DB_USERNAME', 'sa'),
    'password' =&gt; env('DB_PASSWORD', ''),
    'charset' =&gt; 'utf8',
    'prefix' =&gt; '',
],
</pre>
<p>After this application should be able to successfully connect to MS Sql server.</p>
<p>To import database, copy database *.BAK files to project folder, open sqlcmd console</p>
<pre class="brush: bash; title: ; notranslate">
sqlcmd -U sa -P 'Secret123'
</pre>
<p>and run following queries to import MYDB.BAK database backup file</p>
<pre class="brush: sql; title: ; notranslate">
RESTORE DATABASE &#x5B;mydb] FROM DISK='/home/vagrant/project/MYDB.BAK'
WITH  FILE = 1,  
MOVE N'MYDB_dat' TO N'/var/opt/mssql/data/mydb.mdf',
MOVE N'MYDB_log' TO N'/var/opt/mssql/data/mydb.ldf',
NOUNLOAD,  REPLACE,  STATS = 1
GO
</pre>
<p>That&#8217;s basically all to install and run MS SQL on your Homestead Vagrant box, if you have any questions, feel free to contact!</p>
<p>The post <a href="https://vedmant.com/ms-sql-vagrant-ubuntu-homestead-box-development-laravel/">MS SQL on Vagrant Ubuntu Homestead box for development on Laravel</a> appeared first on <a href="https://vedmant.com">vedmant.com :: coding blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://vedmant.com/ms-sql-vagrant-ubuntu-homestead-box-development-laravel/feed/</wfw:commentRss>
			<slash:comments>6</slash:comments>
		
		
			</item>
	</channel>
</rss>
