Mysql Commands: Difference between revisions
Jump to navigation
Jump to search
Line 24: | Line 24: | ||
=User Management= | =User Management= | ||
* Show users | * Show users | ||
<code> MariaDB [(none)]> mysqlselect host, user, password from mysql.user; </code> | : <code> MariaDB [(none)]> mysqlselect host, user, password from mysql.user; </code> | ||
* Show grants to a user | * Show grants to a user | ||
<code> MariaDB [(none)]> HOW GRANTS FOR 'dbusername'@'%'; </code> | : <code> MariaDB [(none)]> HOW GRANTS FOR 'dbusername'@'%'; </code> | ||
Here dbusername is the name of the user that is used to handle database access | Here dbusername is the name of the user that is used to handle database access | ||
*Revoke all grants to a user | *Revoke all grants to a user | ||
<code> MariaDB [(none)]> REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'dbusername'@'%'; </code> | : <code> MariaDB [(none)]> REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'dbusername'@'%'; </code> | ||
*Delete a user | *Delete a user | ||
<code> MariaDB [(none)]> DROP USER 'dbusername'@'%'; </code> | : <code> MariaDB [(none)]> DROP USER 'dbusername'@'%'; </code> | ||
=Access Rights Management= | =Access Rights Management= | ||
=Table Management= | =Table Management= | ||
=Backup Management= | =Backup Management= |
Revision as of 08:39, 13 January 2020
Installation
- Installation on ubuntu server through terminal
sudo apt install mariadb-server
sudo mysql_secure_installation
sudo systemctl status mariadb
- Start or stop mariadb server services
sudo systemctl stop mariadb
sudo systemctl start mariadb
Database Management
- Create database: param
- Using defaults
mysql> CREATE DATABASE param;
- Using specific parameters
mysql> CREATE DATABASE param DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
- Delete database: param
mysql> DROP DATABASE param;
- List the databases created in the database server
SHOW DATABASES;
- Use a particular database and see all the tables in the database
use param;
MariaDB [param]> shwo tables;
User Management
- Show users
MariaDB [(none)]> mysqlselect host, user, password from mysql.user;
- Show grants to a user
MariaDB [(none)]> HOW GRANTS FOR 'dbusername'@'%';
Here dbusername is the name of the user that is used to handle database access
- Revoke all grants to a user
MariaDB [(none)]> REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'dbusername'@'%';
- Delete a user
MariaDB [(none)]> DROP USER 'dbusername'@'%';