MySQL...and related

So, these days I'm trying to learn some Ess-Queue-Ell, or Sequel, using MySQL. Now, this MySQL is hosted on a CentOS machine - a VM. Hopefully this  deployment diagram (UML) might help to throw some light on this:


So far, it is only configuring the MySQL Workbench on Windows8.1, and then accessing a MySQL database on CentOS, following commands were used to achieve this:

1. Create a user which can connect to remote machine:
mysql>Create user 'RemoteDBA'@'localhost'  identified by  "abcd";

2. Grant Privileges to connect:
mysql>Grant all privileges on *.* to 'RemoteDBA'@'windows.machine.ip'  identified by  "abcdef";
..notice the extra ef -this password is different!

3. On CentOS, add an exception to iptables / firewall, so that this PC could connect it:

First see if that port is open - type this from your Window:
c:\>telnet ip.of.Linux.machine 3306
If you see something like not allowed to connect, then type following on CentOS:
#firewall-cmd --zone=public --add-port=3306/tcp --permanent
#firewall-cmd --reload
4. On MySQL Workbench, add the user as:
user: RemoteDBA
hostname: my.Linux.machine
passwod - abcdef (NOTICE the "ef" - this won't work if you do a local login like mysql -u RemoteDBA -p ....abcdef) it is only for the remote part.



Some helpful command for troubleshooting:

See what is kept in your IP tables on Linux:
#iptables -L
#cat /etc/sysconfig/iptables

Start / stop the iptables-daemon:
#service iptables stop/start

Start/stop MySQL service:
#service mysqld start
or
#systemctl start mysqld

See what is in Log for MySQL:
#cat /var/log/mysqld.log
MySQL settings are kept in: /etc/my.cnf

Change owner from root to mysql - may help if starting up of mysql failes:
#chown mysql:mysql /var/lib/mysql  -cRh
#chown mysql:mysql /var/run/mysql  -cRh


No comments:

Post a Comment