<?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>node.js ile mysql bağlantısı - hknsoft</title>
	<atom:link href="https://hknsoft.com/etiket/node-js-ile-mysql-baglantisi/feed/" rel="self" type="application/rss+xml" />
	<link></link>
	<description>Android, Yazılım, Script</description>
	<lastBuildDate>Sat, 21 Oct 2023 09:07:33 +0000</lastBuildDate>
	<language>tr</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0</generator>

<image>
	<url>https://hknsoft.com/wp-content/uploads/2020/05/cropped-icon-hknsoft-150x150.png</url>
	<title>node.js ile mysql bağlantısı - hknsoft</title>
	<link></link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Node.js ile MySQL Bağlantısı</title>
		<link>https://hknsoft.com/node-js-ile-mysql-baglantisi/</link>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Sun, 28 May 2023 14:19:00 +0000</pubDate>
				<category><![CDATA[Node.js]]></category>
		<category><![CDATA[node js ile mysql veritabanına bağlanma]]></category>
		<category><![CDATA[node.js ile mysql]]></category>
		<category><![CDATA[node.js ile mysql bağlantısı]]></category>
		<category><![CDATA[node.js mysql sorgu çalıştırma]]></category>
		<guid isPermaLink="false">https://hknsoft.com/?p=1287</guid>

					<description><![CDATA[<p>Node.js ile MySQL bağlantısı yapabilmek için öncelikle projemize mysql kütüphanesini eklemeliyiz. Artık MySQL bağlantısı kurabiliriz. Not: Kod yazmaya başlamadan önce makinanızda MySQL&#8217;i çalıştırın. XAMPP ya <a class="mh-excerpt-more" href="https://hknsoft.com/node-js-ile-mysql-baglantisi/" title="Node.js ile MySQL Bağlantısı">[...]</a></p>
<p>The post <a href="https://hknsoft.com/node-js-ile-mysql-baglantisi/">Node.js ile MySQL Bağlantısı</a> appeared first on <a href="https://hknsoft.com">hknsoft</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">Node.js ile MySQL bağlantısı yapabilmek için öncelikle projemize <a href="https://www.npmjs.com/package/mysql" target="_blank" rel="noreferrer noopener nofollow" class="broken_link"><strong>mysql</strong></a> kütüphanesini eklemeliyiz.</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">npm install mysql</pre></div>



<p class="wp-block-paragraph">Artık MySQL bağlantısı kurabiliriz.</p>



<p class="wp-block-paragraph"><strong>Not:</strong> Kod yazmaya başlamadan önce makinanızda MySQL&#8217;i çalıştırın. <a href="https://www.apachefriends.org/tr/index.html" target="_blank" rel="noreferrer noopener nofollow"><strong>XAMPP</strong></a> ya da WAMPP gibi yazılımları kullanabilirsiniz.</p>



<h2 class="wp-block-heading">Bağlantı Oluşturma</h2>



<p class="wp-block-paragraph"><strong>database.js</strong> adında bir dosya oluşturuyoruz.</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">const mysql = require('mysql');

// database ayarları
const db = mysql.createConnection({
    host: 'localhost',
    user: 'root',
    password: 'password',
    database: 'database_name'
});

// yukarıdaki bilgilere göre database bağlanıyoruz
db.connect(function (err) {
    // eğer bir hata oluşursa programı durdurup hatayı konsola yazdıracak
    if (err) throw err;

    // başarılı bir şekilde bağlandığını konsola yazdırıyoruz
    console.log('connection successful');
});

// db objesini export ediyoruz ki bu dosyayı çağırdığımız yerde sorgular çalıştırabilelim
module.exports = db;</pre></div>



<h2 class="wp-block-heading">Sorgu Çalıştırma</h2>



<p class="wp-block-paragraph">Yukarıda oluşturduğumuz <strong>database.js</strong> dosyasını projemizin istediğimiz yerinde <strong>çağırarak</strong> sorgular çalıştırabiliriz.</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">// database dosyamızı çağırıyoruz
const db = require('./database.js');

// sorgu çalıştırıyoruz
db.query(`SELECT * FROM players WHERE id = '107861148515'`, (err, result) =&gt; {
    if (err) throw err;
    var row = result[0];

    if (result.length &gt; 0) {
        console.log(row);
    } else {
        console.log('player not found');
    }
});</pre></div>



<h2 class="wp-block-heading has-text-align-center"><a href="https://gist.github.com/fovelas/a50848c2bb2d0ddaeead94d3e43f74f3" target="_blank" rel="noreferrer noopener nofollow"><strong>GitHub</strong></a></h2>
<p>The post <a href="https://hknsoft.com/node-js-ile-mysql-baglantisi/">Node.js ile MySQL Bağlantısı</a> appeared first on <a href="https://hknsoft.com">hknsoft</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
