Founded by Alexander the Great on the Mediterranean coast in 322 b.c. , Alexandria was capital of Egypt during the Ptolemaic era .
Alexandria remained the capital of Egypt for twenty years after its founding .