sudo apt update
sudo apt install mysql-server
sudo systemctl status mysql
sudo mysql_secure_installation
sudo mysql
SHOW VARIABLES LIKE 'validate_password%';
SET global validate_password.length=4;
CREATE USER 'kh'@'localhost' IDENTIFIED BY '1234';
DROP USER 'kh'@'localhost';
CREATE USER 'kh'@'192.168.50.219' IDENTIFIED BY '1234';
DROP USER 'kh'@'192.168.50.219';
# 請參考下方的允許遠端存取
CREATE USER 'kh'@'%' IDENTIFIED BY '1234';
DROP USER 'kh'@'%';
# REVOKE ALL ON *.* FROM 'kh'@'localhost';
GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES, RELOAD on *.* TO 'kh'@'localhost';
GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES, RELOAD on *.* TO 'kh'@'192.168.50.219';
GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES, RELOAD on *.* TO 'kh'@'%';
FLUSH PRIVILEGES;
SHOW GRANTS FOR 'kh'@'localhost';
source /home/kh/XXX/scripts/mysql.sql;
EXIT
mysql -u kh -p
# ref:
# https://www.digitalocean.com/community/tutorials/how-to-install-mysql-on-ubuntu-20-04
允許遠端存取:
- sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf
bind-address = 0.0.0.0
- sudo systemctl restart mysql
- ref:
- https://www.digitalocean.com/community/tutorials/how-to-allow-remote-access-to-mysql