Add users to MYSQL

Standard

Setting up a mysql database for a user
======================================

Note. There is a very popular administration tool called phpMyAdmin at
http://www.phpmyadmin.net


Login to mysql and add an accout and a new database.
—————————————————

1. Login to mysql with your mysql root password:
Note. If this fails, maybe this is a first time login. See below.

$ mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.
mysql>

2. Use the MYSQL admin database

mysql> use mysql;

3. Add a user called XXX with password YYY:

mysql> insert into user (host, user, password) values(‘localhost’, ‘XXX’, password(‘YYY’));
Query OK, 1 row affected (0.04 sec)


4. Create a database for WWW called ZZZ:

mysql> create database ZZZ;
Query OK, 1 row affected (0.01 sec)

5. Allow XXX to administer the database called ZZZ:

mysql> grant all privileges on ZZZ.* to ‘XXX’;
Query OK, 0 rows affected (0.02 sec)

6. Tell mysql to update the mysql users and exit:

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

First time root login to mysql only.
———————————–

1. First time mysql login (no mysql root password set yet):

$ mysql -uroot
Welcome to the MySQL monitor.
mysql>

2. Set your system wide mysql root password. Change the xxxxxx to your
password. Be careful to keep the quotemarks around the word root and
your xxxxxx:

mysql> use mysql;
Database changed
mysql> update user set password=password(‘xxxxxx’) where user=’root’;
Query OK, 2 rows affected (0.00 sec)
Rows matched: 2 Changed: 2 Warnings: 0

3. Finish:

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


Disclaimer:
By reading and/or using the information within this web page you agree to hold the author, publisher and all related entities harmless from any claim directly or indirectly related to the information given or the use of any part of the information on this web site. Use at own risk. No responsibility taken.