tags: mysql, cheatsheet date: 2022-05-24
sudo -u mysql mysqld --verbose --skip-grant-tables
Run:
mysql
In MariaDB/MySQL shell run:
use mysql
UPDATE user SET authentication_string=PASSWORD('c00lpassw0rd') WHERE user='root';
You can start the MariaDB daemon with:
/usr/bin/mysqld_safe --datadir='/var/lib/mysql'
CREATE USER 'dbuser'@'localhost' IDENTIFIED BY 'str0ngpassw0rd';
GRANT ALL PRIVILEGES ON dbname.* TO 'dbuser'@'localhost';
Add index on field:
ALTER TABLE stat ADD INDEX (hostname);
ALTER TABLE stat ADD INDEX (created);
Add index on two fields:
ALTER TABLE stat ADD INDEX `hostname_created_index`(`hostname`, `created`);
SHOW INDEX FROM `stat`;
DROP INDEX hostname ON stat;