gumara

เหนือกว่าเหตุผล ผมไม่มีเหตุผล

Database

backupclub

วันนี้นั่งว่างๆ เลยแบคอัพคลับซะหน่อย แบคอัพเฉพาะ db ได้มาขนาดเท่านี้

[silk]$ ls -lh ubuntuclub.080517.sql.tar
-rw-rw-r-- 1 ubuntuclub pg1112472 674M 2008-05-17 03:56 ubuntuclub.080517.sql.tar

นี่ลบ error log table ของ smf ที่ขนาด 500 กว่าเม็กทิ้งไปแล้วนะ

ก็ นั่ง backup มือ ทีละ table เลย เข้าใจเลยว่าทำไมเวลาสั่งด้วยสคริปแล้วโดน dreamhost kill ทิ้งทุกที

แก้เออเรอร์ database

database ของ thaiopensource error สาเหตุมาจาก พี่ปุ๋ยเก็บไฟล์จนล้นฮาร์ดดิสก์ แล้วมันเก็บข้อมูลไม่ได้ ก็เลยขึ้นเออเรอร์ ทีนี้พี่อ้นเคลียร์พื้นที่ฮาร์ดดิสก์ให้แล้ว restart mysql แล้ว เออเรอร์ยังไม่หาย

เออเรอร์ขึ้นตามนี้
Warning: Table './web3_db1/newtos_sessions' is marked as crashed and should be repaired query: SELECT u.*, s.* FROM newtos_users u INNER JOIN newtos_sessions s ON u.uid = s.uid WHERE s.sid = 'cbc5e6404866947d36187a1ca5303361' in /var/www/web3/web/includes/database.mysql.inc on line 172

Warning: Table './web3_db1/newtos_cache_page' is marked as crashed and should be repaired query: SELECT data, created, headers, expire FROM newtos_cache_page WHERE cid = 'http://thaiopensource.org/' in /var/www/web3/web/includes/database.mysql.inc on line 172

Connect Database อื่นใน Drupal

วิธี Connect database ตัวอื่นใน Drupal ครับ จดเก็บไว้ อนาคตได้ใช้ประโยชน์แน่นอน

First define the database connections Drupal can use by editing the $db_url string in the Drupal configuration file (settings.php for 4.6 and above, otherwise conf.php). By default only a single connection is defined

<?php
$db_url = 'mysql://drupal:drupal@localhost/drupal';
?>

To allow multiple database connections, convert $db_url to an array.

<?php
$db_url['default'] = 'mysql://drupal:drupal@localhost/drupal';
$db_url['mydb'] = 'mysql://user:pwd@localhost/anotherdb';
$db_url['db3'] = 'mysql://user:pwd@localhost/yetanotherdb';
?>

Note that database storing your Drupal installation should be keyed as the default connection.

To query a different database, simply set it as active by referencing the key name.

<?php
db_set_active('mydb');

db_query('SELECT * FROM table_in_anotherdb');

//Switch back to the default connection when finished.
db_set_active('default');
?>

Make sure to always switch back to the default connection so Drupal can cleanly finish the request lifecycle and write to its system tables.

เหตุที่ต้อง node+1

คราวก่อนอัพเกรด drupal แล้วมีปัญหา ทำให้มีเหตุให้ต้องลงไปงม database ของ drupal แล้วเจอวิธีจัดการ databaseแบบที่ผมงงๆอยู่ แต่วันนี้เข้าใจแล้ว

คือเวลาเขียนข้อมูลลงไป มันจะบอกเลขว่า node นี้เลขเท่าไหร่ แล้วมันก็จะเก็บค่านั้นไว้ในช่องนึง ซึ่งครั้งต่อไปที่จะเพิ่มข้อมูล มันจะเอาเลขในช่องนั้น มา +1 แล้วเก็บเป็น หมายเลขของ node ที่เราจะเพิ่มในครั้งนี้ ทีนี้ที่ผมงงคือ มันจะเก็บเลขแล้วเอามา +1 ทำไม ในเมื่อมันใช้ autoincrement ก็ได้นี่นา (เรียก autoincrement ป่าวหว่า ลืมแล้ว)

rMilk

Comment

Tags

Another ~


Let's chat

User login

del.icio.us/~

Add to Technorati Favorites


Stat:

free web tracker