Thursday, February 24, 2011

MySQL setup

When you install mysql server, on your system, you need to some basic things so
taht you can seamlessly access it from any other machine.

1) By default, root user is created without password for Mysql server.

2) From Server , you can connect to MySQL Server using commandline mysql client.
using user root

$ mysql -u root -p

do not enter any password.

3) by default, MySQL Server is binded locally because of this you can not access it from other machines.
You need to comment out following in /etc/mysql/my.cnf

#bind-address = 127.0.0.1


4) Still with root, you can not access mysql server from remote machine, solution to this is to create a user with sufficient permissions.

mysql> CREATE USER 'magic'@'localhost' IDENTIFIED BY 'magic123'
-> ;
Query OK, 0 rows affected (0.00 sec)

mysql> GRANT ALL PRIVILEGES ON *.* TO 'magic'@'localhost' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)

mysql> CREATE USER 'magic'@'%' IDENTIFIED BY 'magic123';
Query OK, 0 rows affected (0.00 sec)

mysql> GRANT ALL PRIVILEGES ON *.* TO 'magic'@'%' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)


I did this mysql setup for number of times but still everytime I go to following link http://dev.mysql.com/doc/refman/5.1/en/adding-users.html


Disclaimer:
This post is for my own reference.

No comments: