Switch user to root:
$ su -u root -p
Run codes to add user and grant all privileges
$ CREATE USER 'user'@'localhost' IDENTIFIED BY 'pass';
$ CREATE USER 'user'@'%' IDENTIFIED BY 'pass';
$ GRANT ALL ON *.* TO 'user'@'localhost';
$ GRANT ALL ON *.* TO 'user'@'%';