MYSQL / MARIADB commandos

[Inloggen in Mariadb] mysql -u root -p


CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';

GRANT ALL PRIVILEGES ON *.* TO 'username'@'localhost' WITH GRANT OPTION;

CREATE USER 'username'@'%' IDENTIFIED BY 'password';

GRANT ALL PRIVILEGES ON *.* TO 'username'@'%' WITH GRANT OPTION;

FLUSH PRIVILEGES;

 

 

show databases;

CREATE DATABASE db1;
Query OK, 1 row affected (0.18 sec)

CREATE DATABASE db1;
ERROR 1007 (HY000): Can't create database 'db1'; database exists

CREATE OR REPLACE DATABASE db1;
Query OK, 2 rows affected (0.00 sec)

CREATE DATABASE IF NOT EXISTS db1;
Query OK, 1 row affected, 1 warning (0.01 sec)

SHOW WARNINGS;
+-------+------+----------------------------------------------+
| Level | Code | Message |
+-------+------+----------------------------------------------+
| Note | 1007 | Can't create database 'db1'; database exists |
+-------+------+----------------------------------------------+

drop database test01;

SELECT User FROM mysql.user;

SELECT host, user FROM mysql.user;

SELECT host, user, password FROM mysql.user;

show grants for 'vivek'@'%';


show tables from mysql;

show full tables from mysql;

show columns from Jokes_table from test;
+---------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------------+--------------+------+-----+---------+----------------+
| JokeID | int(11) | NO | PRI | NULL | auto_increment |
| Joke_question | varchar(500) | NO | | NULL | |
| Joke_answer | varchar(500) | NO | | NULL | |
+---------------+--------------+------+-----+---------+----------------+
3 rows in set (0.001 sec)

 


alter user testuser identified by 'wachtwoord';


MariaDB [(none)]> select password ('wachtwoord');
+-------------------------------------------+
| password ('wachtwoord') |
+-------------------------------------------+
| *B33F1075E48B7CB3B733C3B84DACE4FBD1135C97 |
+-------------------------------------------+
1 row in set (0.000 sec)

MariaDB [(none)]>