Friday, June 03, 2005

Create user in MySQL

You can easily add mysql new user as follows:

mysql -u root -p mysql
mysql> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'localhost'
-> IDENTIFIED BY 'some_pass' WITH GRANT OPTION;
mysql> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'%'
-> IDENTIFIED BY 'some_pass' WITH GRANT OPTION;
mysql> GRANT RELOAD,PROCESS ON *.* TO 'admin'@'localhost';
mysql> GRANT USAGE ON *.* TO 'dummy'@'localhost';
mysql> FLUSH PRIVILEGES;

Note: don't know why, the mysql won't complain if you don't supply the -p command switch, even the user really requires password. But even you have reached the mysql prompt, you won't have any further access.

By default, mysqld don't listen on external network interface other than loopback. To add it back,
comment out the following line in /etc/mysql/my.cnf (or whereever it's located)

#bind-address = 127.0.0.1

No comments: