Changes

Jump to: navigation, search

OPS345 Lab 4

844 bytes added, 01:26, 9 January 2022
Create an SQL user
* Try it anyway just to see the error:
<source>MariaDB [(none)]> grant all privileges on firstdb.* TO 'asmith15db'@'%' identified by 'andrewdbpasswordasmith15dbpassword';
ERROR 1044 (42000): Access denied for user 'dbroot'@'%' to database 'firstdb'</source>
Instead creating a user in AWS RDS takes these three steps:
#Create a user with this username and password (replace andrewdb asmith15db with yours):<source>CREATE USER 'asmith15db'@'%' IDENTIFIED BY 'asmith15dbpassword';</source>
#Find what privileges your dbroot is able to assign:<source>show grants for 'dbroot';</source>
#Give the most important permissions to your db user:<source>GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE ON firstdb.* TO 'asmith15db'@'%';</source>
 
* Quit the SQL session where you're logged in as dbroot and log in as your new user instead:
<source>MariaDB [(none)]> quit
Bye
[asmith15@www ~]$ mysql -u asmith15db -pasmith15dbpassword -h ops345db.cnjsjcelkwzu.us-east-1.rds.amazonaws.com
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 1375
Server version: 10.5.12-MariaDB-log managed by https://aws.amazon.com/rds/
 
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
 
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
 
MariaDB [(none)]>
</source>
 
* Execute '''show databases;''' - note that the list of databases is shorter. That's because your user doesn't have access to all the databases whcih dbroot has access to.
* Execute '''use firstdb''' and '''show tables'''. You have access to the firstdb databases, but there aren't any tables in it. You need to create your own.
* [https://www.guru99.com/mariadb-tutorial-install.html#6 This MariaDB tutorial] is as simple as it gets for creating tables, inserting data into them, and retrieving data. Follow it if you have the time.
<source></source>
<source></source>
* Log out from root
* mysql -u andrewdb -pandrewdbpassword -h ops345db.cobdogt5aykb.us-east-1.rds.amazonaws.com
* show databases; - note that the list is shorter.
* use firstdb;
* show tables;
* Create tables, insert data, select: https://www.guru99.com/mariadb-tutorial-install.html#6
* A realistic use case for your career: download and instal nextcloud.
* wget the .tar.bz2 (not zip)

Navigation menu