MariaDB
This section covers various commands and procedures for managing MariaDB.
Install
Installs MariaDB and runs the secure installation script.
Root password
This subsection provides methods for changing the root password in MariaDB.
Hot change
Changes the root password without restarting the MariaDB service.
Cold change
Changes the root password after stopping and starting the MariaDB service.
systemctl mariadb stop
mysqld_safe --skip-grant-tables &
mysql mysql -u root
UPDATE user SET password=PASSWORD('NEWPASSWORD') WHERE user="root";
FLUSH PRIVILEGES;
exit
systemctl mariadb start
User split
Creates a new database and grants privileges to a user.
mysqladmin -u root -p create MYDB
mysql -u root -p mysql
GRANT ALL ON MYDB.* TO MYUSER@'%' IDENTIFIED BY 'NEWPASSWORD';
GRANT ALL ON MYDB.* TO MYUSER@localhost IDENTIFIED BY 'NEWPASSWORD';
FLUSH PRIVILEGES;
exit
Extract permissions
Displays the SQL commands needed to recreate the grants for each user.
use mysql
select distinct concat('SHOW GRANTS FOR ''' , user, '''@''',host,''';') as query from user;
Tables
This subsection provides commands related to database tables.
Copy
Creates a new table by copying an existing one.
Log requests
This subsection explains how to log MariaDB requests.
Activate
Enables the general query log.
Destination
Specifies where the general query log should be stored.
Table
select * from general_log;
select * from mysql.general_log where command_type = 'Query' and user_host = 'user[user] @ localhost []'
File
Deactivate
Disables the general query log.
Upgrade
This subsection explains how to upgrade MariaDB.