1. SSH to the server using your favourite CLI.
  2. switch to a superuser
    # sudo su
    # cd /var/lib/mysql
  3. dump from live database to an actual .sql file
    # mysqldump live_database > live_database.sql
  4. change the URL in the database
    # sed -i 's/livedomain.com/stagingdomain.com/g' ./live_database.sql
  5. Import the modified dump to the staging database
    # mysql staging_database < ./live_database.sql
  6. remove the dump file
    # rm live_database.sql

If you see the message: “Please login as the user “centos” rather than the user “root”  we need to allow root access via SSH.

Now you can SSH as root to your instance, high five!

© 2021 - FreshLondon