MariaDB Veritabanı Yönetimi ve Kullanımı
MariaDB, MySQL kökenli, yüksek performanslı, ölçeklenebilir ve güvenilir açık kaynak bir ilişkisel veritabanı yönetim sistemidir. ServBay, MariaDB ile birlikte gelir ve bu makalede MariaDB veritabanının ServBay içerisinde nasıl yönetileceği ve kullanılacağı detaylı bir şekilde anlatılacaktır. Bu, kurulum, yapılandırma, yedekleme, geri yükleme ve performans optimizasyonu gibi konuları kapsar.
MariaDB Kurulumu ve Yapılandırması
ServBay, MariaDB ile birlikte gelir, sadece çalışır durumda olduğundan emin olunmalı ve gerekli yapılandırmalar yapılmalıdır.
MariaDB Hizmetini Başlatma ve Yönetme
MariaDB hizmetini ServBay yönetim platformu veya komut satırı aracı servbayctl
aracılığıyla yönetebilirsiniz.
ServBay Yönetim Platformunu Kullanma
- ServBay yönetim platformunu açın.
- "Hizmetler"e gidin.
- MariaDB hizmetini bulun ve başlatma, durdurma veya yeniden başlatma işlemlerini gerçekleştirin.
Komut Satırı Aracı servbayctl
Kullanma
# MariaDB hizmetini başlat
servbayctl start mariadb 11.3
# MariaDB hizmetini durdur
servbayctl stop mariadb 11.3
# MariaDB hizmetini yeniden başlat
servbayctl restart mariadb 11.3
2
3
4
5
6
7
8
MariaDB'nin Yapılandırılması
ServBay'in varsayılan MariaDB yapılandırma dosyası optimize edilmiştir. Kullanıcı yapılandırma dosyasını değiştirmek isterse, my.cnf
dosyasını şu yolda bulabilir:
/Applications/ServBay/etc/mariadb/11.3/my.cnf
Farklı MariaDB sürümlerine göre, yapılandırma dosyası farklı dizinlerde bulunur.
MariaDB'ye Bağlanma
MariaDB'ye komut satırı aracı mysql
veya phpMyAdmin ve Adminer gibi grafiksel araçlar ile bağlanabilirsiniz.
Komut Satırı ile Bağlanma
TCP/IP ile bağlanma:
bashmysql -u your_username -p -h localhost -P 3306
1Socket ile bağlanma:
bashmysql -u your_username -p -S /Applications/ServBay/tmp/mysql.sock
1
phpMyAdmin ve Adminer ile Bağlanma
ServBay varsayılan olarak phpMyAdmin ve Adminer ile birlikte gelir, bunlara şu şekilde erişebilirsiniz:
- Erişim Adresi:
https://servbay.host
Bu sayfada, phpMyAdmin ve Adminer girişlerini bulacak ve ServBay yönetim panelinden elde edilen kullanıcı adı ve parola ile giriş yapabileceksiniz.
Veritabanı Yönetimi
Veritabanı ve Kullanıcı Oluşturma
Veritabanı oluşturma:
sqlCREATE DATABASE mydatabase;
1Kullanıcı oluşturma ve yetki verme:
sqlCREATE USER 'your_username'@'localhost' IDENTIFIED BY 'your_password'; GRANT ALL PRIVILEGES ON mydatabase.* TO 'your_username'@'localhost'; FLUSH PRIVILEGES;
1
2
3
Yedekleme ve Geri Yükleme
Veritabanı Yedekleme
Yedekleme dosyasını şu dizine kaydetmenizi öneririz:
/Applications/ServBay/backup/mariadb
Veritabanını mysqldump
aracı ile yedekleyin:
mysqldump -u your_username -p mydatabase > /Applications/ServBay/backup/mariadb/mydatabase.sql
Veritabanı Geri Yükleme
Veritabanını mysql
aracı ile geri yükleyin:
mysql -u your_username -p mydatabase < /Applications/ServBay/backup/mariadb/mydatabase.sql
Performans Optimizasyonu
MariaDB, çeşitli performans optimizasyon seçenekleri sunar. İşte sık kullanılan bazı optimizasyon yöntemleri.
İndeks Optimizasyonu
Sık kullanılan sorgu sütunları için indeks oluşturduğunuzdan emin olun. Örneğin:
CREATE INDEX idx_column_name ON your_table_name(column_name);
Sorgu Optimizasyonu
Sorgu performansını analiz etmek ve gereken optimizasyonu yapmak için EXPLAIN
komutunu kullanın. Örneğin:
EXPLAIN SELECT * FROM your_table_name WHERE column_name = 'value';
Yapılandırma Optimizasyonu
Performansı arttırmak için yapılandırma dosyasındaki parametreleri ayarlayın. Örneğin, tampon havuzu boyutunu ayarlayın:
[mysqld]
innodb_buffer_pool_size = 1G
2
Güvenlik Yönetimi
Veritabanı güvenliği oldukça önemlidir, işte bazı güvenlik yönetimi önerileri.
Güçlü Parolalar Ayarlama
Tüm veritabanı kullanıcıları için güçlü parolalar ayarlayın:
SET PASSWORD FOR 'your_username'@'localhost' = PASSWORD('your_new_password');
Düzenli Yedekleme
Veri kaybını önlemek için düzenli olarak veritabanı yedeklemeleri yapın.
Erişimi Sınırlandırma
Veritabanı kullanıcılarının erişim izinlerini sınırlandırın, sadece gerekli izinleri verin:
REVOKE ALL PRIVILEGES ON *.* FROM 'your_username'@'localhost';
GRANT SELECT, INSERT, UPDATE ON mydatabase.* TO 'your_username'@'localhost';
2
Sık Karşılaşılan Sorunlar ve Çözümleri
MariaDB'ye Bağlanamıyor
MariaDB'nin çalışıp çalışmadığını kontrol edin:
bashservbayctl status mariadb 11.3
1Güvenlik duvarı ayarlarını kontrol edin: MariaDB'nin portunun (varsayılan 3306) güvenlik duvarından geçmesine izin verdiğinizden emin olun.
Yetki Sorunları
Kullanıcı yetkilerini kontrol edin:
sqlSHOW GRANTS FOR 'your_username'@'localhost';
1Gerekli yetkileri verin:
sqlGRANT ALL PRIVILEGES ON mydatabase.* TO 'your_username'@'localhost'; FLUSH PRIVILEGES;
1
2
Sonuç
MariaDB, güçlü ve esnek bir veritabanı yönetim sistemidir. ServBay ile birlikte gelen MariaDB, veritabanı yönetimini ve kullanımını daha da kolaylaştırır. Bu makale aracılığıyla MariaDB'nin kurulumu, yapılandırılması, bağlantısı, yönetimi, yedeklenmesi, geri yüklenmesi ve performans optimizasyonu gibi konularda bilgi sahibi olabilir, veritabanınızın verimli ve güvenli bir şekilde çalışmasını sağlayabilirsiniz.