# Truy cập MariaDB từ xa trên Centos

> Truy cập MariaDB từ xa trên Centos

- URL: https://vietanhjs.com/truy-cap-mariadb-tu-xa-tren-centos.html
- Chuyên mục: [Thiết lập môi trường](https://vietanhjs.com/thiet-lap-moi-truong)
- Tác giả: [Hoàng Văn Việt Anh](https://hoangvanvietanh.com/)
- Xuất bản: 2022-05-14T09:33:28+07:00
- Cập nhật: 2022-08-07T16:57:04+07:00

---

Đăng nhập vào SQL:

```

mysql -u root -p
```

Thêm tài khoản SQL

```

GRANT ALL PRIVILEGES ON *.* TO 'remoteuser'@'%' IDENTIFIED BY 'new_password' WITH GRANT OPTION;
```

Cho phép tài khoản truy cập từ xa

```

GRANT ALL PRIVILEGES ON *.* TO 'remoteuser'@'192.168.52.43' IDENTIFIED BY 'new_password' WITH GRANT OPTION;
```

Lệnh cuối cùng để apply

```

FLUSH PRIVILEGES;
```

#Open MySQL Port

# open port

```

sudo firewall-cmd --permanent --add-port=3306/tcp
```

# reload

```

sudo firewall-cmd --reload
```
