Commandes memo
Tables
Show Table Schema
DESCRIBE TABLE_NAME;
Create Tabletable
CREATE TABLE nom_de_la_table
(
colonne1 type_donnees,
colonne2 type_donnees,
colonne3 type_donnees,
colonne4 type_donnees
)
Users & Permissions
Create User & Del User
CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';<br>
DROP USER ‘username’@‘localhost’;
Users Password
Change Password User
UPDATE mysql.user SET Password=PASSWORD('new-password-here') WHERE USER='user-name-here' AND Host='host-name-here';
Privileges
Add Privileges:
GRANT ALL PRIVILEGES ON * . * TO 'newuser'@'localhost';
- ALL PRIVILEGES- as we saw previously, this would allow a MySQL user full access to a designated database (or if no database is selected, global access across the system)
- CREATE- allows them to create new tables or databases
- DROP- allows them to them to delete tables or databases
- DELETE- allows them to delete rows from tables
- SERT- allows them to insert rows into tables
- SELECT- allows them to use the SELECT command to read through databases
- UPDATE- allow them to update table rows
- GRANT OPTION- allows them to grant or remove other users' privileges
Revoke Privileges
REVOKE type_of_permission ON database_name.table_name FROM ‘username’@‘localhost’;
Show user privileges
SHOW GRANTS username;
Docs
→ SQL.SH Create Tables
→ How To Create a New User and Grant Permissions in MySQL
→ MySQL Change a User Password
→ Mémo SQL pour la Data Science
→ Jointure SQL
→ CheatSheet SQL