How to building pretty URLs to reflect category hierarchy?

Change the Settings -> Permalink to Custom Structure /%category%/%postname%/

Now while editing the post, check only the subcategory and now the parent category is nested within the URL automatically.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)