Database mysql

Creating a user and set password mysql

I’ve had a few problems creating users, assigning passwords and granting access to uses in MySQL.
Below is one method I’ve found that works, at least for WordPress databases.

mysql> create database wordpressdb;
mysql> create user 'wordpressuser'@'localhost';
mysql> set password for 'wordpressuser'@'localhost'=PASSWORD('password');
mysql> use wordpressdb;
mysql> grant all on * to 'wordpressuser'@'localhost';