MySQL

Importiranje SQL-a sa diska u bazu na server:
mysql -pŠIFRA -hlocalhost baza < baza.sql


Exportiranje SQL-a iz baze na disk:
mysql -pŠIFRA -h localhost baza > baza.sql

dump svih baza
mysqldump -u username -ppassword --all-databases > dump.sql


import svih baza
mysql -u root -psecret < dump.sql

Instaliranje najnovije verzije iz source-a:
nano mysql_source_install.sh

Kopirati u mysql_source_install.sh datoteku/skriptu slijedeći sadržaj:

#!/bin/bash

VERSION=5.6
RELEASE=8-rc

echo  -n " Are you ready to start. !  1 = YES | 0 = NO: "
read start

if (($start > 0 ))
then
        echo "OK then... : ";
else
        exit;
fi


echo -n " What Version are you downloading? (ie: $VERSION)  :    "
read VERSION

if [ -z "$VERSION" ]
then
  echo -n "Need a Version ";
  exit;
else
  echo ""
fi

echo -n " What release is it of $VERSION ? ie: $VERSION.($RELEASE)  :    "
read RELEASE

if [ -z "$RELEASE" ]
then
  echo -n "Need a release";
  exit;
else
  echo ""
fi

echo " Where are you located: "
echo " Europe - 1 ";
echo " North America - 2 ";
echo " Latin America - 3";
echo " Asia - 4 ";
echo " Africa - 5 ";
echo " Oceania -6 ";

read LOCATION


if [ "$LOCATION " -eq "1" ]
then
 echo " Europe ";
 URL="ftp.sunet.se/pub/unix/databases/relational/mysql"
elif  [ "$LOCATION " -eq "2" ]
then
 URL="mysql.mirrors.hoobly.com"

elif  [ "$LOCATION " -eq "3" ]
then
 URL="mysql.cce.usp.br"

elif  [ "$LOCATION " -eq "4" ]
then
 URL="mysql.ntu.edu.tw"

elif  [ "$LOCATION " -eq "5" ]
then
 URL="mysql.mirror.ac.za"

elif  [ "$LOCATION " -eq "6" ]
then
 URL="mysql.mirrors.ilisys.com.au"

else
 echo " Invalid Location ";
 exit;
fi



echo "Downloading  mysql-$VERSION.$RELEASE.tar.gz  to /usr/local/src/  FROM $URL  ";
wget http://dev.mysql.com/get/Downloads/MySQL-$VERSION/mysql-$VERSION.$RELEASE.tar.gz/from/http://$URL/  -O mysql-$VERSION.$RELEASE.tar.gz


echo  -n " Can I continue?. !  1 = YES | 0 = NO: "
read start
exit;
if (($start > 0 ))
then
        echo "Unpacking.... ";
else
        exit;
fi

tar -vxzf mysql-$VERSION.$RELEASE.tar.gz

cd mysql-$VERSION.$RELEASE


echo "Install tools...";

apt-get install cmake
apt-get install g++
apt-get install libncurses5-dev
apt-get install bison
apt-get install libaio-dev


cmake -LAH > options
cmake .
make
make install
make install scripts


cd /usr/local/mysql
chown -R mysql .
chgrp -R mysql .

scripts/mysql_install_db --user=mysql

# chown -R root .
# chown -R mysql data

./bin/mysqld_safe --user=mysql &
./bin/mysql_secure_installation

cp support-files/my-huge.cnf /etc/my.cnf


ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql

echo "MySQL tools installed in /usr/local/mysql/bin/ ";

mysql -p


chmod +x mysql_source_install.sh

./mysql_source_install.sh

Comments