You can add users and change privileges by issuing direct SQL statements, if you are connected using a suitably privileged MySQL userID.
...
However, I don't recommend building "privileged things" into ordinary user programs. Several reasons: (a) there are lots of good admin tools already out there, why invent another; (b) odds aren't too good that your user will have the necessary privs; (c) you really don't want a program to log-on "by default" as a privileged soul.