Android

วิธีการติดตั้ง mysql บน debian 10 linux

Debian 10: Installing MySQL (not MariaDB) (non APT Repository)

Debian 10: Installing MySQL (not MariaDB) (non APT Repository)

สารบัญ:

Anonim

MySQL ระบบจัดการฐานข้อมูลเชิงสัมพันธ์โอเพนซอร์สที่เป็นที่นิยมมากที่สุดในโลกไม่สามารถใช้งานได้ในพื้นที่เก็บข้อมูลเริ่มต้นของ Debian MariaDB เป็นระบบฐานข้อมูลเริ่มต้นใน Debian 10

บทช่วยสอนนี้อธิบายวิธีการติดตั้งและรักษาความปลอดภัย MySQL บน Debian 10 จาก MySQL Apt Repository

การกำหนดค่า MySQL Repository

ในการเพิ่มที่เก็บ MySQL APT ลงในระบบของคุณให้ไปที่หน้าดาวน์โหลดที่เก็บและดาวน์โหลดแพ็คเกจล่าสุดโดยใช้คำสั่ง wget ต่อไปนี้:

wget

เมื่อการดาวน์โหลดเสร็จสิ้นให้ติดตั้งแพ็กเกจรีลีสในฐานะผู้ใช้ที่มีสิทธิ์ sudo:

sudo apt install./mysql-apt-config_0.8.13-1_all.deb

คุณจะได้รับการนำเสนอด้วยเมนูการตั้งค่าซึ่งคุณสามารถเลือกรุ่น MySQL ที่คุณต้องการติดตั้ง

เมื่อการติดตั้งเสร็จสมบูรณ์บริการ MySQL จะเริ่มโดยอัตโนมัติคุณสามารถตรวจสอบได้โดยพิมพ์:

sudo systemctl status mysql

● mysql.service - MySQL Community Server Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: en Active: active (running) since Fri 2019-07-26 13:23:25 PDT; 37s ago…

การรักษาความปลอดภัย MySQL

รันคำสั่ง mysql_secure_installation เพื่อตั้งค่ารหัสผ่านรูทและเพื่อปรับปรุงความปลอดภัยของการติดตั้ง MySQL:

sudo mysql_secure_installation

Securing the MySQL server deployment. Connecting to MySQL using a blank password. VALIDATE PASSWORD COMPONENT can be used to test passwords and improve security. It checks the strength of password and allows the users to set only those passwords which are secure enough. Would you like to setup VALIDATE PASSWORD component? Press y|Y for Yes, any other key for No:

คุณจะถูกขอให้กำหนดค่า VALIDATE PASSWORD PLUGIN ซึ่งใช้ในการทดสอบความแข็งแรงของรหัสผ่านผู้ใช้ MySQL นโยบายการตรวจสอบรหัสผ่านมีสามระดับต่ำปานกลางและรัดกุม กด ENTER หากคุณไม่ต้องการตั้งค่าปลั๊กอินรหัสผ่านที่ถูกต้อง

Please set the password for root here. New password: Re-enter new password:

ในพรอมต์ถัดไปคุณจะถูกขอให้ตั้งรหัสผ่านสำหรับผู้ใช้รูท MySQL

By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? (Press y|Y for Yes, any other key for No): y Success. Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? (Press y|Y for Yes, any other key for No): y Success. By default, MySQL comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? (Press y|Y for Yes, any other key for No): y - Dropping test database… Success. - Removing privileges on test database… Success. Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? (Press y|Y for Yes, any other key for No): y Success. All done!

เมื่อคุณตั้งรหัสผ่านรูทแล้วสคริปต์จะขอให้คุณลบผู้ใช้ที่ไม่ระบุชื่อออกให้ จำกัด การเข้าถึงของผู้ใช้รูทไปยังเครื่องโลคัลและลบฐานข้อมูลทดสอบ คุณควรตอบ“ Y” (ใช่) สำหรับทุกคำถาม

เชื่อมต่อกับเซิร์ฟเวอร์ MySQL

ในการโต้ตอบกับ MySQL ผ่านเทอร์มินัลใช้ไคลเอนต์ mysql ซึ่งติดตั้งเป็นการอ้างอิงของแพ็คเกจเซิร์ฟเวอร์ MySQL

หากคุณเลือกวิธีการรับรองความถูกต้องเริ่มต้นเพื่อเข้าสู่เซิร์ฟเวอร์ MySQL เป็นประเภทผู้ใช้รูท:

sudo mysql

มิฉะนั้นหากคุณเลือกวิธีการรับรองความถูกต้องดั้งเดิมเพื่อเข้าสู่ระบบประเภท:

mysql -u root -p

คุณจะได้รับแจ้งให้ป้อนรหัสผ่านรูทที่คุณตั้งไว้ก่อนหน้านี้เมื่อ mysql_secure_installation สคริปต์ mysql_secure_installation เมื่อคุณป้อนรหัสผ่านคุณจะพบกับเปลือก MySQL ดังที่แสดงด้านล่าง:

Welcome to the MySQL monitor. Commands end with; or \g. Your MySQL connection id is 10 Server version: 8.0.17 MySQL Community Server - GPL…

ข้อสรุป

ในบทช่วยสอนนี้คุณได้เรียนรู้วิธีการติดตั้งและรักษาความปลอดภัยเซิร์ฟเวอร์ MySQL บนเซิร์ฟเวอร์ Debian 10 นอกจากนี้เรายังแสดงวิธีเชื่อมต่อกับเชลล์ MySQL ด้วย

หากแอปพลิเคชันของคุณไม่มีข้อกำหนดเฉพาะคุณควรใช้ MariaDB ซึ่งเป็นระบบฐานข้อมูลเริ่มต้นใน Debian 10

mysql debian