Skip to content
Snippets Groups Projects

MariaDB

reset unknown root password

MariaDB-Service

systemctl stop mariadb.service
mysqld_safe --skip-grant-tables --skip-networking &

MariaDB

mysql -u root
mysql> use mysql;
mysql> select Host,User,Password,plugin,authentication_string from user;
mysql> update user set password=PASSWORD("mysql") where User='root';
mysql> update user set plugin='' where User='root';
mysql> flush privileges;
mysql> exit

MariaDB-Service

mysqladmin shutdown -u root -p
systemctl start mariadb.service

add local user

mysql -u root -p mysql
mysql> create database tw;
mysql> GRANT ALL PRIVILEGES ON *.* TO 'tw'@'localhost' IDENTIFIED BY 'Password' WITH GRANT OPTION;
mysql> GRANT ALL PRIVILEGES ON tw.* TO 'tw'@'localhost' IDENTIFIED BY 'Password' WITH GRANT OPTION;
mysql> flush privileges;
mysql> exit
mysql -u tw -p tw
mysql> show databases;
mysql> SELECT USER(), CURRENT_USER();
mysql> exit
sudo systemctl restart mariadb.service

add user covid19data

mysql -u root -p mysql
mysql> create database covid19data;
mysql> GRANT ALL PRIVILEGES ON *.* TO 'covid19data'@'localhost' IDENTIFIED BY 'covid19datapwd';
mysql> GRANT ALL PRIVILEGES ON covid19data.* TO 'covid19data'@'localhost' IDENTIFIED BY 'covid19datapwd';
mysql> flush privileges;
mysql> exit
mysql -u covid19data -p covid19data
mysql> show databases;
mysql> SELECT USER(), CURRENT_USER();
mysql> exit
sudo systemctl restart mariadb.service