CREATE USER 'username'@'192.168.0.5' IDENTIFIED BY 'password'
username 你要創建的帳號 password 密碼 192.168.0.5 改成本機ip
GRANT ALL PRIVILEGES ON db_name.* TO 'username'@'192.168.0.%';
db_name 你要連的db
192.168.0.5 ifconfig cmd
mysql設定
nano /etc/mysql/mysql.conf.d/mysqld.cnf
bind-address = 127.0.0.1
修改成你的主機ip
bind-address = 192.168.1.20
重啟mysql service mysql restart
mysql -h 192.168.1.20 -u account -p
本機連線成功即可再試遠端主機 account是你剛剛創建的帳號