[CentOS] Connect to MySQL monitor on another host in the LAN ?

Niki Kovacs contact at kikinovak.net
Tue Mar 23 16:56:43 UTC 2010


Hi,

I'm running a medical application on a local network, using MySQL as a 
database. The application can also connect to remote hosts, so the idea 
is to install it on one machine acting as a "server", and then install 
it on the other machines on the LAN, but configure these to use the 
database on the "server". I guess before doing that, I'll better try and 
get comfortable with connecting remotely using the MySQL monitor itself, 
that is, without any application or some other frontend.

Up until now, I've only configured MySQL in two situations. Either on 
standalone desktop workstations, or on a web server (LAMP).

After installing MySQL (yum install mysql-server), the default setup has 
a few accounts without any password. First thing I usually do (correct 
me if this is wrong) is clean up these accounts and only keep one main 
root at localhost account. Something like this :

[root at raymonde:~] # mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.0.77 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> select user, host, password from user;
+------+-----------+----------+
| user | host      | password |
+------+-----------+----------+
| root | localhost |          |
| root | raymonde  |          |
| root | 127.0.0.1 |          |
|      | localhost |          |
|      | raymonde  |          |
+------+-----------+----------+
5 rows in set (0.00 sec)

mysql> delete from user where user = '';
Query OK, 2 rows affected (0.01 sec)

mysql> delete from user where host = 'raymonde';
Query OK, 1 row affected (0.00 sec)

mysql> delete from user where host = '127.0.0.1';
Query OK, 1 row affected (0.01 sec)

mysql> select user, host, password from user;
+------+-----------+----------+
| user | host      | password |
+------+-----------+----------+
| root | localhost |          |
+------+-----------+----------+
1 row in set (0.00 sec)

mysql>  set password for root at localhost = password('********');
Query OK, 0 rows affected (0.00 sec)

mysql> select user, host, password from user;
+------+-----------+------------------+
| user | host      | password         |
+------+-----------+------------------+
| root | localhost | 2d97271980b60f82 |
+------+-----------+------------------+
1 row in set (0.00 sec)

mysql> quit;

So much for the standalone setup.

Now what would be an orthodox (and somewhat secure) configuration to be 
able to connect to this MySQL server on 'raymonde' from another machine 
in the LAN ? Do I have to (re)create a root at raymonde MySQL account and 
eventually give it the same password than root at localhost ?

Cheers,

Niki


More information about the CentOS mailing list