Skip to content

Instantly share code, notes, and snippets.

@clicktechnology
Created November 9, 2021 12:14
Show Gist options
  • Save clicktechnology/3672c3318d6ee0c2859de0d8167d2d64 to your computer and use it in GitHub Desktop.
Save clicktechnology/3672c3318d6ee0c2859de0d8167d2d64 to your computer and use it in GitHub Desktop.
LOGIN AS ROOT
-----------------------------------------------------------------------------------------
morgan@server:~$ mysql -uroot -p
Password:
DELETE TEST DB/ TEST USER IF THEY EXIST
-----------------------------------------------------------------------------------------
mysql> DROP DATABASE IF EXISTS testdb;
Query OK, 0 rows affected (0,01 sec)
mysql> DROP USER IF EXISTS 'testdb_user'@'localhost';
Query OK, 0 rows affected (0,00 sec)
CREATE DB AND USER
-----------------------------------------------------------------------------------------
mysql> CREATE DATABASE testdb;
mysql> CREATE USER 'testdb_user'@'localhost' IDENTIFIED BY 'Aea13e456u($#iOiuzsdiut&IKZUg786'; | Make pw sufficiently long to avoid errors
mysql> GRANT CREATE,INSERT,DELETE,UPDATE,SELECT ON testdb.* TO 'testdb_user'@'localhost'; | Apply ususal rights to user. User can't create other users.
mysql> FLUSH PRIVILEGES;
mysql> exit
TEST NEW USER ACCOUNT
-----------------------------------------------------------------------------------------
morgan@sqlserver:~$ mysql -utestdb_user -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 33596
Server version: 5.7.34-log MySQL Community Server (GPL)
Copyright (c) 2000, 2021, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| testdb |
+--------------------+
2 rows in set (0,00 sec)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment