Reset root password

https://videotutorialzone.com/mysql/how-to-reset-mysql-8-root-password-on-ubuntu-20-04

Install mysql

#Install mysql 
sudo apt install mysql-server
sudo mysql_secure_installation
- N 
set any password 
- Y
- N
- Y
- Y
-------
sudo mysql
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'STRONG_PASSWORD_HERE';
FLUSH PRIVILEGES;

Import and Export MySql

Export : mysqldump -u root -p db > db.sql #one db
			 : mysqldump -u root -p --all-databases > alldb.sql # all dbs
			 : for DB in $(mysql -uroot -p -e 'show databases' -s --skip-column-names); do mysqldump -u root -p""  $DB > "$DB.sql"; done

mysqldump -h <host> -u <username> -p <schema> --no-data > db-structure.sql #ignore all data inside tables
mysqldump -h <host> -u <username> -p <schema> --no-create-info --ignore-table=schema.table1 --ignore-table=schema.table2 > db-data.sql #ignore some tables

Import : mysql -u root -p db < db.sql

Change Mysql Password

# option1
$ sudo mysql -u root # I had to use "sudo" since is new installation

mysql> USE mysql;
mysql> UPDATE user SET plugin='mysql_native_password' WHERE User='root';
mysql> FLUSH PRIVILEGES;
mysql> exit;

$ sudo service mysql restart

#option2
$ sudo mysql -u root # I had to use "sudo" since is new installation

mysql> USE mysql;
mysql> CREATE USER 'YOUR_SYSTEM_USER'@'localhost' IDENTIFIED BY 'YOUR_PASSWD';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'YOUR_SYSTEM_USER'@'localhost';
mysql> UPDATE user SET plugin='auth_socket' WHERE User='YOUR_SYSTEM_USER';
mysql> FLUSH PRIVILEGES;
mysql> exit;

$ sudo service mysql restart

Transfer database from server to another

mysqldump --all-databases -uuser -ppassword -hserver -P3306 --force | mysql -hremoteserver -uremoteuser -premotepassword -P3306 --force

Create access User from any location

CREATE USER 'root'@'%' IDENTIFIED BY '';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;
---
sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf
bind-address            = 0.0.0.0