{"id":12414,"date":"2013-07-01T09:19:00","date_gmt":"2013-07-01T09:19:00","guid":{"rendered":"https:\/\/kiencang.net\/2013\/07\/01\/ket-noi-co-so-du-lieu-mysql-voi-php-de-chay-thu-tai-localhost\/"},"modified":"2013-07-01T09:19:00","modified_gmt":"2013-07-01T09:19:00","slug":"ket-noi-co-so-du-lieu-mysql-voi-php-de-chay-thu-tai-localhost","status":"publish","type":"post","link":"https:\/\/kiencang.net\/ket-noi-co-so-du-lieu-mysql-voi-php-de-chay-thu-tai-localhost\/","title":{"rendered":"K\u1ebft n\u1ed1i c\u01a1 s\u1edf d\u1eef li\u1ec7u MySQL v\u1edbi PHP \u0111\u1ec3 ch\u1ea1y th\u1eed t\u1ea1i Localhost"},"content":{"rendered":"\n
D\u01b0\u1edbi \u0111\u00e2y l\u00e0 code m\u1eabu \u0111\u1ec3 k\u1ebft n\u1ed1i c\u01a1 s\u1edf d\u1eef li\u1ec7u (database) v\u1edbi PHP \u0111\u1ec3 ch\u1ea1y th\u1eed t\u1ea1i Localhost:<\/p>\n\n\n\n
<?php\n$dsn = 'mysql:host=localhost;dbname=ten_co_so_du_lieu';\n$username = 'root';\n$password = '';\n$db = new PDO($dsn, $username, $password);\n?><\/code><\/pre>\n\n\n\nGi\u1ea3i th\u00edch:<\/p>\n\n\n\n
mysql:host=localhost<\/code>: Ch\u1ec9 ra \u0111\u1ecba ch\u1ec9 host c\u1ee7a d\u1eef li\u1ec7u MySQL. V\u00ec b\u1ea1n \u0111ang ch\u1ea1y th\u1eed tr\u00ean m\u00e1y t\u00ednh c\u00e1 nh\u00e2n n\u00ean b\u1ea1n \u0111\u1ec3 l\u00e0 localhost, trong tr\u01b0\u1eddng h\u1ee3p ch\u1ea1y tr\u00ean hosting m\u00e0 b\u1ea1n thu\u00ea th\u00ec ph\u1ea3i \u0111\u1ed5i t\u00ean t\u01b0\u01a1ng \u1ee9ng.<\/li>dbname=ten_co_so_du_lieu<\/code>: B\u1ea1n \u0111i\u1ec1n t\u00ean c\u1ee7a c\u01a1 s\u1edf d\u1eef li\u1ec7u b\u1ea1n mu\u1ed1n k\u1ebft n\u1ed1i.<\/li>username<\/code> \u0111\u1ec3 l\u00e0 root<\/code> v\u00e0 pass<\/code> \u0111\u1ec3 l\u00e0 r\u1ed7ng. L\u01b0u \u00fd l\u00e0 v\u00ec b\u1ea1n \u0111ang ch\u1ea1y th\u1eed tr\u00ean localhost n\u00ean kh\u00f4ng c\u1ea7n b\u1ea3o m\u1eadt th\u00ec pass m\u1edbi \u0111\u1ec3 r\u1ed7ng. Khi ch\u1ea1y tr\u00ean hosting th\u00ec b\u1ea1n kh\u00f4ng \u0111\u01b0\u1ee3c ph\u00e9p \u0111\u1ec3 pass r\u1ed7ng – v\u00ec n\u1ebfu \u0111\u1ec3 r\u1ed7ng ng\u01b0\u1eddi kh\u00e1c c\u00f3 th\u1ec3 x\u00e2m nh\u1eadp CSDL.<\/li>$db = new PDO($dsn, $username, $password)<\/code>: \u0110\u00e2y l\u00e0 code t\u1ea1o PDO (PHP Data Objects) – PHP 5.0 tr\u1edf l\u00ean \u0111\u1ec1u c\u00f3 h\u1ed7 tr\u1ee3.<\/li><\/ul>\n","protected":false},"excerpt":{"rendered":"D\u01b0\u1edbi \u0111\u00e2y l\u00e0 code m\u1eabu \u0111\u1ec3 k\u1ebft n\u1ed1i c\u01a1 s\u1edf d\u1eef li\u1ec7u (database) v\u1edbi PHP \u0111\u1ec3 ch\u1ea1y th\u1eed t\u1ea1i Localhost: Gi\u1ea3i th\u00edch: mysql:host=localhost: Ch\u1ec9 ra \u0111\u1ecba ch\u1ec9 host c\u1ee7a d\u1eef li\u1ec7u MySQL. V\u00ec b\u1ea1n \u0111ang ch\u1ea1y th\u1eed tr\u00ean m\u00e1y t\u00ednh c\u00e1 nh\u00e2n n\u00ean b\u1ea1n \u0111\u1ec3 l\u00e0 localhost, trong tr\u01b0\u1eddng h\u1ee3p ch\u1ea1y tr\u00ean hosting m\u00e0 b\u1ea1n …<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[238],"tags":[],"yoast_head":"\n
K\u1ebft n\u1ed1i c\u01a1 s\u1edf d\u1eef li\u1ec7u MySQL v\u1edbi PHP \u0111\u1ec3 ch\u1ea1y th\u1eed t\u1ea1i Localhost • Ki\u1ebfn c\u00e0ng<\/title>\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t\n\t\n\t\n","yoast_head_json":{"title":"K\u1ebft n\u1ed1i c\u01a1 s\u1edf d\u1eef li\u1ec7u MySQL v\u1edbi PHP \u0111\u1ec3 ch\u1ea1y th\u1eed t\u1ea1i Localhost • Ki\u1ebfn c\u00e0ng","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/kiencang.net\/ket-noi-co-so-du-lieu-mysql-voi-php-de-chay-thu-tai-localhost\/","og_locale":"vi_VN","og_type":"article","og_title":"K\u1ebft n\u1ed1i c\u01a1 s\u1edf d\u1eef li\u1ec7u MySQL v\u1edbi PHP \u0111\u1ec3 ch\u1ea1y th\u1eed t\u1ea1i Localhost • Ki\u1ebfn c\u00e0ng","og_description":"D\u01b0\u1edbi \u0111\u00e2y l\u00e0 code m\u1eabu \u0111\u1ec3 k\u1ebft n\u1ed1i c\u01a1 s\u1edf d\u1eef li\u1ec7u (database) v\u1edbi PHP \u0111\u1ec3 ch\u1ea1y th\u1eed t\u1ea1i Localhost: Gi\u1ea3i th\u00edch: mysql:host=localhost: Ch\u1ec9 ra \u0111\u1ecba ch\u1ec9 host c\u1ee7a d\u1eef li\u1ec7u MySQL. V\u00ec b\u1ea1n \u0111ang ch\u1ea1y th\u1eed tr\u00ean m\u00e1y t\u00ednh c\u00e1 nh\u00e2n n\u00ean b\u1ea1n \u0111\u1ec3 l\u00e0 localhost, trong tr\u01b0\u1eddng h\u1ee3p ch\u1ea1y tr\u00ean hosting m\u00e0 b\u1ea1n …","og_url":"https:\/\/kiencang.net\/ket-noi-co-so-du-lieu-mysql-voi-php-de-chay-thu-tai-localhost\/","og_site_name":"Ki\u1ebfn c\u00e0ng","article_author":"https:\/\/www.facebook.com\/anhducnguyen87\/","article_published_time":"2013-07-01T09:19:00+00:00","author":"Nguy\u1ec5n \u0110\u1ee9c Anh","twitter_card":"summary_large_image","twitter_misc":{"\u0110\u01b0\u1ee3c vi\u1ebft b\u1edfi":"Nguy\u1ec5n \u0110\u1ee9c Anh","\u01af\u1edbc t\u00ednh th\u1eddi gian \u0111\u1ecdc":"1 ph\u00fat"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/kiencang.net\/ket-noi-co-so-du-lieu-mysql-voi-php-de-chay-thu-tai-localhost\/","url":"https:\/\/kiencang.net\/ket-noi-co-so-du-lieu-mysql-voi-php-de-chay-thu-tai-localhost\/","name":"K\u1ebft n\u1ed1i c\u01a1 s\u1edf d\u1eef li\u1ec7u MySQL v\u1edbi PHP \u0111\u1ec3 ch\u1ea1y th\u1eed t\u1ea1i Localhost • Ki\u1ebfn c\u00e0ng","isPartOf":{"@id":"https:\/\/kiencang.net\/#website"},"datePublished":"2013-07-01T09:19:00+00:00","dateModified":"2013-07-01T09:19:00+00:00","author":{"@id":"https:\/\/kiencang.net\/#\/schema\/person\/5e7e1a04d8d1218ad8c421ba43d25c16"},"breadcrumb":{"@id":"https:\/\/kiencang.net\/ket-noi-co-so-du-lieu-mysql-voi-php-de-chay-thu-tai-localhost\/#breadcrumb"},"inLanguage":"vi","potentialAction":[{"@type":"ReadAction","target":["https:\/\/kiencang.net\/ket-noi-co-so-du-lieu-mysql-voi-php-de-chay-thu-tai-localhost\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/kiencang.net\/ket-noi-co-so-du-lieu-mysql-voi-php-de-chay-thu-tai-localhost\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/kiencang.net\/"},{"@type":"ListItem","position":2,"name":"K\u1ebft n\u1ed1i c\u01a1 s\u1edf d\u1eef li\u1ec7u MySQL v\u1edbi PHP \u0111\u1ec3 ch\u1ea1y th\u1eed t\u1ea1i Localhost"}]},{"@type":"WebSite","@id":"https:\/\/kiencang.net\/#website","url":"https:\/\/kiencang.net\/","name":"Ki\u1ebfn c\u00e0ng","description":"\u00d4m l\u00fd thuy\u1ebft, h\u00f4n th\u1ef1c h\u00e0nh","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/kiencang.net\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"vi"},{"@type":"Person","@id":"https:\/\/kiencang.net\/#\/schema\/person\/5e7e1a04d8d1218ad8c421ba43d25c16","name":"Nguy\u1ec5n \u0110\u1ee9c Anh","image":{"@type":"ImageObject","inLanguage":"vi","@id":"https:\/\/kiencang.net\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/6d71f9b89393952a8382e30dad26c1ec?s=96&d=monsterid&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/6d71f9b89393952a8382e30dad26c1ec?s=96&d=monsterid&r=g","caption":"Nguy\u1ec5n \u0110\u1ee9c Anh"},"description":"Sinh n\u0103m 1987, t\u1ed1t nghi\u1ec7p Cao \u0111\u1eb3ng th\u1ef1c h\u00e0nh FPT qu\u00e3ng 2014, chuy\u00ean ng\u00e0nh Thi\u1ebft k\u1ebf website. T\u00f4i th\u00edch Content, SEO, Ads, T\u0103ng t\u1ed1c website v\u00e0 Th\u01b0\u01a1ng m\u1ea1i \u0111i\u1ec7n t\u1eed. B\u00ean c\u1ea1nh b\u00e0i t\u1ef1 vi\u1ebft, t\u00f4i c\u0169ng d\u1ecbch nhi\u1ec1u n\u1ed9i dung th\u00fa v\u1ecb c\u1ee7a c\u00e1c t\u00e1c gi\u1ea3 kh\u00e1c nhau. FB c\u00e1 nh\u00e2n: facebook.com\/anhducnguyen87. Email li\u00ean h\u1ec7: guiemailchotoi@gmail.com","sameAs":["https:\/\/www.facebook.com\/anhducnguyen87\/"],"url":"https:\/\/kiencang.net\/author\/admin\/"}]}},"_links":{"self":[{"href":"https:\/\/kiencang.net\/wp-json\/wp\/v2\/posts\/12414"}],"collection":[{"href":"https:\/\/kiencang.net\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kiencang.net\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kiencang.net\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kiencang.net\/wp-json\/wp\/v2\/comments?post=12414"}],"version-history":[{"count":0,"href":"https:\/\/kiencang.net\/wp-json\/wp\/v2\/posts\/12414\/revisions"}],"wp:attachment":[{"href":"https:\/\/kiencang.net\/wp-json\/wp\/v2\/media?parent=12414"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kiencang.net\/wp-json\/wp\/v2\/categories?post=12414"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kiencang.net\/wp-json\/wp\/v2\/tags?post=12414"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}