Add Guest Order to a Customer Account in Magento
To get the customer_id simply go to Customers > Manage Customers in the Magento admin.
Log in to the MySQL and execute the following queries:
UPDATE sales_flat_order SET customer_id = (YOUR-CUSTOMER-ID), customer_is_guest=0 WHERE entity_id = YOUR-ORDER-ID AND customer_id IS NULL
UPDATE sales_flat_order_grid SET customer_id = YOUR-CUSTOMER-ID WHERE entity_id = YOUR-ORDER-ID AND customer_id IS NULL