gumara

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

MySQL

Reset MySQL root password

นึกไม่ถึงว่า MySQL มันจะ Reset root password ง่ายขนาดนี้

sudo /etc/init.d/mysql reset-password

แก้เออเรอร์ 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

backup db เฉพาะ prefix ที่ต้องการ

backup db เฉพาะ prefix ที่ต้องการ

ขอบคุณสุกรีค๊าบบ สุกรนีสุดยอด ให้สิบคะแนน

TAB=`mysqlshow -uuser -ppass drupaldb|grep ^\||cut -f2 -d' '|grep ^prefix`
mysqldump -uuser -ppass drupaldb $TAB > output.sql

ย้ายเรียบร้อย

ก็ บันทึกเล็กๆ จากประสพการณ์ย้ายคลับ

แต่เดิม ไฟล์ในคลับจะอยู่ที่โฟลเดอร์ของ user ที่ใช้สำหรับ gumara.com อยู่ ก็จะย้ายไปโฟลเดอร์ของ user ubuntuclub ไปเลย แยกไปต่างหาก แล้วก็ db ด้วย แต่ทั้ง gumara.com และ ubuntuclub อยู่บนเซิร์ฟเวอร์เครื่องเดียวกัน เลยสะดวกหน่อย

ขั้นแรก ย้ายไฟล์ก่อน

ก็ไม่มีไรพิเศษ เนื่องจากอยู่เซิร์ฟเวอร์เดียวกัน และมีสิทธิ์ read อยู่แล้ว ก็ก๊อบมาหมดเลย

ก็
cp -R /home/user_gumara/ubuntuclub.com/* /home/user_club/ubuntuclub.com/
cp -R /home/user_gumara/forum.ubuntuclub.com/* /home/user_club/forum.ubuntuclub.com/
cp -R /home/user_gumara/wiki.ubuntuclub.com/* /home/user_club/wiki.ubuntuclub.com/

เป็นอันว่าย้ายไฟล์เสร็จแล้ว

ต่อไป ย้าย db

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.

rMilk

Comment

Tags

Another ~


Let's chat

User login

del.icio.us/~

Add to Technorati Favorites


Stat:

free web tracker