Mysql
 sql >> Teknologi Basis Data >  >> RDS >> Mysql

Langkah-langkah untuk menginstal Mysql56 di linux

Pada artikel ini, Anda akan mempelajari langkah-langkah untuk menginstal mysql56 di Linux, sebelum kita mulai mari kita periksa semua dependensi sebelum menginstal MySQL.

Instal dependensi MySQL

sudo yum install ncurses-devel

Unduh kode sumber MySQL

cd /usr/local/src/
wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.19.tar.gz
tar xvfz mysql-5.6.19.tar.gz
cd /usr/local/src/mysql-5.6.19

Membangun mysql

mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local/mysql
make
make install

Penyiapan Awal –  Buat grup dan pengguna

groupadd mysql
useradd -g mysql -d /usr/local/mysql mysql

Buat direktori data MySQL

mkdir /var/lib/mysql
chown -R mysql:mysql /usr/local/mysql

Ubah /etc/my.cnf

[client]
socket=/tmp/mysql.sock

[mysqld]
datadir=/var/lib/mysql
#socket=/var/lib/mysql/mysql.sock
socket=/tmp/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mysqld according to the
# instructions in http://fedoraproject.org/wiki/Systemd
collation-server=utf8_unicode_ci
character-set-server=utf8

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

Membuat basis data

/usr/local/mysql/scripts/mysql_install_db --user=mysql --datadir=/var/lib/mysql -basedir=/usr/local/mysql

Ganti pemilik

chown mysql:mysql -R /var/lib/mysql/*

Salin skrip initd

cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld

Mulai ulang server mysql

/etc/init.d/mysqld restart

Konfirmasi

$ mysql --ssl-ca ca-cert.pem
mysql> show variables like '%ssl%';

+---------------+----------------------------------+
| Variable_name | Value                            |
+---------------+----------------------------------+
| have_openssl  | YES                              |
| have_ssl      | YES                              |
| ssl_ca        | /usr/local/mysql/ca-cert.pem     |
| ssl_capath    |                                  |
| ssl_cert      | /usr/local/mysql/server-cert.pem |
| ssl_cipher    |                                  |
| ssl_crl       |                                  |
| ssl_crlpath   |                                  |
| ssl_key       | /usr/local/mysql/server-key.pem  |
+---------------+----------------------------------+
9 rows in set (0.00 sec)
mysql> show status like 'Ssl_cipher';
+---------------+--------------------+
| Variable_name | Value              |
+---------------+--------------------+
| Ssl_cipher    | DHE-RSA-AES256-SHA |
+---------------+--------------------+
1 row in set (0.00 sec)

Setel SSL:: Buat kunci SSL

$ openssl genrsa 2048 > ca-key.pem
$ openssl req -new -x509 -nodes -days 3600
    -key ca-key.pem -out ca-cert.pem
$ openssl req -newkey rsa:2048 -days 3600 
    -nodes -keyout server-key.pem -out server-req.pem
$ openssl rsa -in server-key.pem -out server-key.pem
$ openssl x509 -req -in server-req.pem -days 3600
    -CA ca-cert.pem -CAkey ca-key.pem -set_serial 01
    -out server-cert.pem

Mengatur file kunci

  • Pindahkan menghasilkan file pem ke direktori /usr/local/mysql/
  • Ubah izin
sudo chmod 400 *.pem
  • Ubah pemilik
sudo chown mysql:mysql *.pem

Ubah my.cnf

[mysqld]
ssl-ca=/usr/local/mysql/ca-cert.pem
ssl-cert=/usr/local/mysql/server-cert.pem
ssl-key=/usr/local/mysql/server-key.pem

Mulai ulang server mysql

sudo /etc/init.d/mysqld restart

Setup Binlog

Buat direktori binlog

sudo mkdir /var/log/mysql
chown mysql:mysql -R /var/log/mysql

Ubah my.cnf

server-id = 888888
log_bin = /var/log/mysql/mysql-bin.log
expire_logs_days = 30
max_binlog_size = 1G
binlog_format = ROW
replicate-wild-do-table = %.%
log-slave-updates = TRUE
binlog-checksum = NONE
log-bin-use-v1-row-events = TRUE
lower_case_table_names = 0

Mulai ulang server mysql

sudo service mysqld restart

Akhir artikel, Ini adalah Langkah-langkah untuk menginstal Mysql56 di Linux.


  1. Database
  2.   
  3. Mysql
  4.   
  5. Oracle
  6.   
  7. Sqlserver
  8.   
  9. PostgreSQL
  10.   
  11. Access
  12.   
  13. SQLite
  14.   
  15. MariaDB
  1. Membuat pengguna di MySQL

  2. Menggunakan seperti wildcard dalam pernyataan yang disiapkan

  3. Sisipkan beberapa baris dengan satu kueri MySQL

  4. KIRI GABUNG hanya baris pertama

  5. Cara Menambahkan Pemisah ke String Gabungan di MySQL – CONCAT_WS()