cs122b-2019-winter-project1: cs122b-setup-scripts.txt

File cs122b-setup-scripts.txt, 2.2 KB (added by michaelwbh, 18 months ago)
Line 
1
2The following instructions are for 64-bit Ubuntu.
3
4Prepared by Prof. Chen Li.
5
6- Install Java:
7
8https://www.digitalocean.com/community/tutorials/how-to-install-java-with-apt-get-on-ubuntu-16-04
9
10shell> sudo apt-get update
11shell> sudo apt-get install default-jre
12shell> sudo apt-get install default-jdk
13shell> javac -version
14
15- Install MySQL
16
17https://help.ubuntu.com/community/JDBCAndMySQL
18
19shell> sudo apt-get install mysql-server
20shell> sudo apt-get install mysql-client
21shell> sudo apt-get install libmysql-java
22
23shell> mysql -u root -p
24
25mysql> CREATE USER 'mytestuser'@'localhost' IDENTIFIED BY 'mypassword';
26mysql> GRANT ALL PRIVILEGES ON * . * TO 'mytestuser'@'localhost';
27
28mysql> create database moviedb;
29mysql> use moviedb;
30
31mysql>  create table stars(
32                id varchar(10) primary key,
33                name varchar(100) not null,
34                birthYear integer
35        );
36                 
37mysql> INSERT INTO stars VALUES('755011', 'Arnold Schwarzeneggar', 1947);
38                 
39mysql> INSERT INTO stars VALUES('755017', 'Eddie Murphy', 1961);
40
41mysql> select * from stars;
42mysql> exit
43
44shell> mysql -u mytestuser -p
45mysql> use moviedb;
46mysql> select * from stars;
47
48
49- Open a new shell:
50
51shell> CLASSPATH=$CLASSPATH:/usr/share/java/mysql.jar
52shell> export CLASSPATH
53shell> javac JDBC1.java
54shell> java JDBC1
55
56
57Start MySQL
58shell> sudo /etc/init.d/mysql start
59
60Stop MySQL
61shell> sudo /etc/init.d/mysql stop
62
63Restart MySQL
64shell> sudo /etc/init.d/mysql restart
65
66- To allow remote access to your AWS EC2 instance, follow instructions at https://mariolurig.com/coding/connect-remotely-mysql-database-amazon-ec2-server/ .  In particular:
67
68 - Change the security group of your EC2 instance to add a rule to allow your local machine to access the MySQL instance (port 3306);
69
70 - On the EC2 instance, create a user for remote access:
71
72shell> mysql -u root -p
73mysql> CREATE USER 'mytestuser'@'%' IDENTIFIED BY 'mypassword';
74mysql> GRANT ALL PRIVILEGES ON * . * TO 'mytestuser'@'%';
75mysql> flush privileges
76
77 - On the EC2 instance, edit the file "/etc/mysql/mysql.conf.d/mysqld.cnf" and comment out the line of "bind-address" to:
78
79#bind-address           = 127.0.0.1
80
81 - Restart MySQL:
82
83shell> sudo /etc/init.d/mysql restart
84
85 - On your local machine:
86
87shell> mysql -u mytestuser -h [EC2_IP_ADDR] -p
88