$ sudo apt-get update
$ sudo apt-get install mariadb-server -y
$ mysql -V
$ sudo mysql_secure_installation
...
- Enter current password for root (enter for none): Just press the Enter
- Set root password? [Y/n]: Y
- New password: Enter password
- Re-enter new password: Repeat password
- Remove anonymous users? [Y/n]: Y
- Disallow root login remotely? [Y/n]: Y
- Remove test database and access to it? [Y/n]: Y
- Reload privilege tables now? [Y/n]: Y
$ sudo vi /etc/mysql/mariadb.conf.d/50-server.cnf
edit or add bind-address
127.0.0.1 to 0.0.0.0
$ sudo systemctl restart mariadb.service
$ sudo netstat -anp | grep 3306
$ sudo apt-get update
$ sudo apt-get install mysql-server -y
$ mysql -V
$ sudo mysql_secure_installation
...
- Enter current password for root (enter for none): Just press the Enter
- Set root password? [Y/n]: Y
- New password: Enter password
- Re-enter new password: Repeat password
- Remove anonymous users? [Y/n]: Y
- Disallow root login remotely? [Y/n]: Y
- Remove test database and access to it? [Y/n]: Y
- Reload privilege tables now? [Y/n]: Y
$ sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf
...
bind-address = <ip address>
$ sudo systemctl restart mysql.service
$ sudo netstat -anp | grep 3306
$mysql -u root
...
CREATE USER 'xxx'@'localhost' IDENTIFIED BY 'xxxx';
GRANT ALL PRIVILEGES ON *.* TO 'xxx'@'localhost' WITH GRANT OPTION;
CREATE USER 'xxx'@'%' IDENTIFIED BY 'xxxx';
GRANT ALL PRIVILEGES ON *.* TO 'xxx'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;
EXIT;
$ mysql -u database_user -p database_user_password -h database_server
Not suggest because not allow all IP addresses not secure