su root mysql -uroot -e " \ ALTER USER 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'yourpasswd'; \ CREATE USER 'root'@'%' IDENTIFIED BY 'yourpasswd'; \ GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'; \ FLUSH PRIVILEGES;"
In /etc/mysql/mysql.conf.d/mysqld.cnf:
replace bind-address = 127.0.0.1 with bind-address = 0.0.0.0