Database & SQL

Accessing DB through cmd

mossybeach 2024. 7. 20. 14:49

a quick and fun tutorial on how to access DB: hacker style :3

 

1.) open cmd and find the DB file 

 

 

some useful CMD keywords to use:

  • cd..: it means to go back a directory.
    you can see everytime we enter it we went back a space, from user1 > Users > C:/ drive
  •  dir:  see a list of all directories when you want to know where to go!

 

2.) find the DB bin where everything is stored

 


3.) log into DB and create user

 

  • bin>mariadb -u root -p: means accessing and logging into the root account, this is where you sign in
  • adding '@'%' behind the usernames means granting the user access to the DB through a different computer, type in password behind indentified by in ' '

4.) select the user and grant privilege

  • *.* means granting all access in the DB to read and change!

  • we can use this command to see access granted for each user

  • we can also use the keyword revoke to take away privilege from a user

5.) Creating a database

 

  • create database command lets you create a new database 
  • the use 'database' lets you navigate into one
  • show databases: let you see all DB that is available
  • to grant a privilege on a specific data base: database name.* to 'username'

6.) creating a table in DB

  • create TABLE tablename (using the name table will result in error) and open bracket
  • press enter to change row: will bring up arrow
  • specify values that will be in the table: no int(n), name varchar(n) etc.
  • close the table by completing the bracket and a semicolon
  • explain table: show the properties of the table made

Additional commands

  • status: view status of a specific DB

  • source: link an external sql file

'Database & SQL' 카테고리의 다른 글

HeidiSQL: sql commands and functions  (0) 2024.07.20
Setting up MariaDB, Heidi SQL  (0) 2024.07.19