Last active
July 26, 2024 10:11
-
-
Save jack2jm/66a6fac04c73a452c009a75bc06da0e2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ubuntu | |
************************* | |
If driver not found error then | |
-> If php version is 8.2, else you can change 8.2 to your preffered php version on server | |
-> Run below command. | |
sudo apt install php8.2-dev | |
sudo update-alternatives --set php /usr/bin/php8.2 | |
sudo update-alternatives --set php-config /usr/bin/php-config8.2 | |
sudo update-alternatives --set phpize /usr/bin/phpize8.2 | |
sudo pecl install -f sqlsrv | |
sudo pecl install -f pdo_sqlsrv | |
sudo phpenmod -v 8.2 sqlsrv pdo_sqlsrv | |
sudo service apache2 restart | |
Install Microsoft odbc driver | |
Copy and paste code from this link - https://learn.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-ver16&tabs=ubuntu18-install%2Calpine17-install%2Cdebian8-install%2Credhat7-13-install%2Crhel7-offline | |
or below command is there. | |
Windows | |
****************** | |
Download required drivers | |
--------- | |
1. Download ODBC driver | |
https://learn.microsoft.com/en-us/sql/connect/odbc/download-odbc-driver-for-sql-server?view=sql-server-ver16#download-for-windows | |
2. Download required php mysql driver for microsoft windows. | |
2.1. download driver from here | |
https://www.microsoft.com/en-us/download/details.aspx?id=20098 | |
2.2 Extract and Install: Extract the downloaded files. | |
Copy the php_sqlsrv_x64.dll and php_pdo_sqlsrv_64.dll files to your PHP extension directory (usually something like C:\xampp\php\ext). | |
2.3 Open the php.ini file located in the C:\xampp\php directory. | |
extension="D:\xamppppppp_82\php\ext\php_sqlsrv_82_ts_x64.dll" | |
extension="D:\xamppppppp_82\php\ext\php_pdo_sqlsrv_82_ts_x64.dll" | |
or change name to dll file like below short name and update ini file like: | |
extension=php_sqlsrv.dll | |
extension=php_pdo_sqlsrv.dll | |
2.4 Restart Apache: | |
Start or restart the Apache server from the XAMPP Control Panel to apply the changes. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. SQLSTATE[23000]: [Microsoft][ODBC Driver 18 for SQL Server][SQL Server]Cannot insert explicit value for identity column in table 'roles' | |
SET IDENTITY_INSERT roles ON | |
//insert entries | |
SET IDENTITY_INSERT roles OFF | |
For Laravel seeders | |
---- | |
Laravel Seeders | |
If you're inserting data through Laravel Seeders, ensure you're not manually setting the id field. (remove id from seeders) | |
2. | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ! [[ "18.04 20.04 22.04 23.04" == *"$(lsb_release -rs)"* ]]; | |
then | |
echo "Ubuntu $(lsb_release -rs) is not currently supported."; | |
exit; | |
fi | |
curl https://packages.microsoft.com/keys/microsoft.asc | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc | |
curl https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/prod.list | sudo tee /etc/apt/sources.list.d/mssql-release.list | |
sudo apt-get update | |
sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18 | |
# optional: for bcp and sqlcmd | |
sudo ACCEPT_EULA=Y apt-get install -y mssql-tools18 | |
echo 'export PATH="$PATH:/opt/mssql-tools18/bin"' >> ~/.bashrc | |
source ~/.bashrc | |
# optional: for unixODBC development headers | |
sudo apt-get install -y unixodbc-dev |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment