นานเท่าไหร่ ไม่ได้ลงแบบทำมือ
ติดตั้ง mysql 5.7 แบบเดิมๆ ผ่าน apt
เป็นเรื่องขนลุกครั้ง ตั้งแต่จำความได้กับการลงmysqlในเครื่อง เพราะแม่งconfigไม่เป็น งงไปหมด คำสั่งบ้าบอ จะลบลงใหม่ก็ไม่หายเกลี้ยงเหมือนconfigยังอยุ่
จนมีเหตุจำเป็นได้ต้องทำ…… spec คร่าวๆ
- บัญชีroot สามารถlogin จากเครื่องอื่นได้
- ตั้งพาสเวิร์ดให้root ไม่ต้องซับซ้อน เอาง่ายๆ
- ติดตั้ง ด้วยคำสั่งนี้
sudo apt-get install mysql-server
(optional***)อาจจะใช้ คำสั่งนี้ก็ได้นะเพื่อตั้งค่าอื่นๆ สะดวกกว่า
mysql_secure_installation
2. เข้าmysql cli ไปเพื่อตั้งค่าเพิ่มเติม
sudo mysql
คำสั่งไว้ดูเล่น 2 คำสั่งก่อนแก้ไข้ค่า
SHOW VARIABLES LIKE ‘validate_password%’;
select user,authentication_string,plugin,host from user;
mysql> use mysql
mysql> SET GLOBAL validate_password_policy=LOW;
mysql> UPDATE mysql.user SET plugin=’mysql_native_password’, authentication_string = password(‘YOUR_SECRET_PASSWORD’), host = ‘%’ WHERE user=’root’;
mysql> FLUSH PRIVILEGES;
3. แก้ไขไฟล์ /etc/mysql/mysql.conf.d/mysqld.cnf ให้รับทุกip
bind-address = 127.0.0.1 แก้เป็น bind-address = 0.0.0.0
หรือคำสั่งนี้แทนก้ได้มันจะ replace ให้
sed -i ‘s/127.0.0.1/0.0.0.0/g’ /etc/mysql/mysql.conf.d/mysqld.cnf
4. เป็นอันจบ รีสาตร์ทได้
sudo service mysql restart
เพิ่มเติม
https://askubuntu.com/questions/640899/how-do-i-uninstall-mysql-completely
https://www.digitalocean.com/community/questions/completely-uninstall-mysql-server
https://www.digitalocean.com/community/questions/how-do-i-uninstall-and-reinstall-mysql
https://www.fosstechnix.com/how-to-install-mysql-5-7-on-ubuntu-20-04-lts/