Creating user, db and granting permission on mysql

To create a user-
mysqladmin –user=root -p create cacti
or
mysql -u root -p
CREATE USER ‘user1’@’localhost’ IDENTIFIED BY ‘pass1’;
GRANT ALL ON *.* TO ‘user1’@’localhost’;
flush privileges;

To create database-
create database <name>;

To set required permission

mysql>grant all on blog.* to blogadm@localhost;
Query OK, 0 rows affected (0.06 sec)

mysql> GRANT USAGE ON blog.* to blogadm@localhost IDENTIFIED BY ‘passwd’;
Query OK, 0 rows affected (0.00 sec)

mysql> GRANT USAGE ON blog.* to blogadm@”%”;
Query OK, 0 rows affected (0.00 sec)

mysql> GRANT USAGE ON blog.* to blogadm@”%” IDENTIFIED BY ‘passwd’;
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: