How to change ip address of mysql server

Changing and access the ip address of mysql server needs some of steps, usually it could be thought as just changing bind IP address in my.cnf file.
(The default ip address of mysql server may be 127.0.0.1.)

Steps,

1. Open my.cnf file
The primary my.cnf is located in /etc/my.cnf. (Mysql server searches my.cnf files from multiple directories from /etc/my.cnf, /etc/mysql/my.cnf, $MYSQL_HOME/my.cnf, [datadir]/my.cnf, ~/my.cnf, etc. It could be different depend on the OS.)


2. Change bind-address field to IP address you want to set.
For example,
[mysqld]
...
#bind-address = 127.0.0.1
bind-address = 62.168.0.100 (example ip address)

And save the file.

3. Restart mysql process.
The command could be different depend on  your OS.
$ /etc/init.d/mysqld restart
or
$ service mysql restart
or 
$ sudo /usr/local/mysql/support-files/mysql.server restart
  
4. Grant the account access rights to connect the mysql server with the IP address remotely.
Connect mysql locally first,

$ mysql -uroot -p

mysql> GRANT ALL ON *.* to root@'62.168.0.100' IDENTIFIED BY 'rootpassword';
mysql> FLUSH PRIVILEGES;

('rootpassword' area should be set with your pasword.)

5. Set password
If your account doesn't have password, set password for it.
mysql > SET PASSWORD FOR 'root'@'62.168.0.100' = PASSWORD('rootpassword');

6. From remote or by using mysql Workbench, connect,
mysql -h62.168.0.100 -uroot -prootpassword


이 블로그의 인기 게시물

둘 중 누군가 그녀를 죽였다, 범인 해설

[MAC OS X] mds_stores 100% CPU usage

tips more on unity ...