Skip to main content

Posts

Showing posts from July, 2015

Connect MySQL Remotely, Amazon EC2 using MySQL Workbench

Login to AWS Management Console. Under the security group, add inbound rule for MySQL. First login to EC2 instance using SSH, then login to mysql  mysql -hlocalhost -uroot -p provide the password. Once you are in mysql prompt CREATE USER 'testuser'@'%' IDENTIFIED BY 'testpwd' GRANT ALL PRIVILEGES ON *.* TO 'testuser'@'%' WITH GRANT OPTION FLUSH PRIVILEGES Note: Setting host to '%' may be harmful, you can set your IP address to access the MySQL from your IP address only Now open the my.cnf file from /etc/mysql and search for bind-address, the default value will be bind-address = 127.0.0.1 change it to  bind-address = 0.0.0.0 That's it now go to MySQL workbench, create connection with Host: Username: testuser  

MySQL Simple JOINS

Simple Example : Lets say you have a Students table, and a Lockers table. Each student can be assigned to a locker, so there is a " Locker Number " column in the student table. More than one student could potentially be in a single locker, but especially at the  beginning  of the school year, you may have some incoming students without lockers and some lockers that have no students assigned. For the sake of this example, lets say you have  100 students , 70 of which have lockers. You have a total of  50 lockers , 40 of which have at least 1 student and 10 lockers have no student. INNER JOIN  is equivalent to " show me all students with lockers ". Any students without lockers, or any lockers without students are missing. Returns 70 rows LEFT OUTER JOIN  would be " show me all students, with their corresponding locker if they have one ". This might be a general student list, or could be used to identify students with no locker. Returns 100 r...