MySQL’ Kategorisi için Arşiv

Install WebSERVERs on Ubuntu

Çarşamba, Ağustos 7th, 2019
cd /tmp; wget --no-check-certificate -O installer.tgz "https://github.com/servisys/ispconfig_setup/tarball/master"; tar zxvf installer.tgz; cd *ispconfig*; bash install.sh

MySQL Database Backup Shell Script

Çarşamba, Ocak 16th, 2019
 #!/bin/bash
# Shell script to backup MySQL database

# Set these variables
MyUSER="" # DB_USERNAME
MyPASS="" # DB_PASSWORD
MyHOST="" # DB_HOSTNAME

# Backup Dest directory
DEST="" # /home/username/backups/DB

# Email for notifications
EMAIL=""

# How many days old files must be to be removed
DAYS=3

# Linux bin paths
MYSQL="$(which mysql)"
MYSQLDUMP="$(which mysqldump)"
GZIP="$(which gzip)"

# Get date in dd-mm-yyyy format
NOW="$(date +"%d-%m-%Y_%s")"

# Create Backup sub-directories
MBD="$DEST/$NOW/mysql"
install -d $MBD

# DB skip list
SKIP="information_schema
another_one_db"

# Get all databases
DBS="$($MYSQL -h $MyHOST -u $MyUSER -p$MyPASS -Bse 'show databases')"

# Archive database dumps
for db in $DBS
do
skipdb=-1
if [ "$SKIP" != "" ];
then
for i in $SKIP
do
[ "$db" == "$i" ] && skipdb=1 || :
done
fi

if [ "$skipdb" == "-1" ] ; then
FILE="$MBD/$db.sql"
$MYSQLDUMP -h $MyHOST -u $MyUSER -p$MyPASS $db > $FILE
fi
done

# Archive the directory, send mail and cleanup
cd $DEST
tar -cf $NOW.tar $NOW
$GZIP -9 $NOW.tar

echo "MySQL backup is completed! Backup name is $NOW.tar.gz" | mail -s "MySQL backup" $EMAIL
rm -rf $NOW

# Remove old files
find $DEST -mtime +$DAYS -exec rm -f {} \;

MySQL & Linux

Çarşamba, Ekim 3rd, 2018

Repository Ekleme

http://dev.mysql.com/downloads/repo/yum/

sudo rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm

Paket Kurulumu

sudo yum -y install mysql-community-server

Sunucuyu Çalıştırma

// Açılışta Servis olarak başlaması için

sudo /usr/bin/systemctl enable mysqld

// Sunucuyu Başlatma

sudo /usr/bin/systemctl start mysqld

Ek Güvenlik Ayarları

sudo /usr/bin/mysql_secure_installation

Öncelikle Firewall tarafıondan 3306 portunu açıyoruz..

firewall-cmd --add-port=3306/tcp 
firewall-cmd --permanent --add-port=3306/tcp

Uzak Bağlantı için Ayarlar;

/etc/my.cfg yada /
içindeki 

[mysqld]
...
skip-networking
...
bind-address = <some ip-address>
...

alanlarını REM ledikten sonra yada 0 yapıtıktan sonra

bind-address = 0.0.0.0

“mysql -u root -p” local den mysql e bağlanarak 

GRANT ALL PRIVILEGES ON . TO 'root'@'%' IDENTIFIED BY 'yeniparola' WITH GRANT OPTION;

yetkisini veriyoruz, yada yeni kullanıcı oluşturuyoruz…!

CREATE USER 'yenikullanici'@'localhost' IDENTIFIED BY 'yeniparola';
CREATE USER 'yenikullanici'@'%' IDENTIFIED BY 'parola';

yerele ve uzağa yetkilerini verelim,

GRANT ALL ON *.* TO 'yenikullanici'@'localhost';
GRANT ALL ON *.* TO 'yenikullanici'@'%';

Son olarak değişiklikleri güncelleyelim,

FLUSH PRIVILEGES;