How to Migrate a WordPress MySQL Database

I very often have to migrate MySQL Databases as I like to spend some time playing with WordPress. So here is an easy and quick way to migrate your DB and avoid manual work when moving a blog from different providers/servers.

Pre-Requisites

  • You must have a pre-configured MySQL server, database and user already created in the destination(new) server
  • You can either use command line or PHPMyAdmin if you have available in the source server
  • Don´t forget to backup your wordpress files/images

From PHPMyAdmin

1. Access your DB

2. Navigate to Export -> Select ¨Quick” and ¨Go¨

3. You will have a .sql file downloaded

From Command Line

1. Access your server where you are migrating from

2. Create WordPress database backup

 

3. Create WordPress files backup

 

4. Restore WordPress DB on the new server

 

5. Restore WordPress files on the new server

Oracle DB – How to select user roles

You can use this SQL script giving the username as argument.

Example:

sqlplus myuser@myDBName @select_roles.sql user1
/* select_roles.sql Script */
select
  lpad(' ', 2*level) || granted_role "User and roles"
from
  (
  /* THE USERS */
    select
      null     grantee,
      username granted_role
    from
      dba_users
    where
      username like upper('%&1%')
  /* THE ROLES TO ROLES RELATIONS */
  union
    select
      grantee,
      granted_role
    from
      dba_role_privs
  )
start with grantee is null
connect by grantee = prior granted_role;