Linux MySQL-5.7.18 release installation guide

Keywords: Swift MySQL socket Linux mysqladmin

The installation process is basically the same as that of the source version. In addition to the compilation phase, this article only talks about the release version, that is, the version with bin file

Benefit: each user can install their own MySQL Server

Target host system: CentOS 6.8
User: saojie (without administrator rights)
Directory: / home/saojie/mysql-5.7.18

download

Linux Generic
Address: https://dev.mysql.com/downloads/mysql/

decompression

tar zxvf mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz
mv mysql-5.7.18-linux-glibc2.5-x86_64 mysql-5.7.18

install

Write profile

Put my.cnf in mysql-5.7.18

[mysqld]
basedir = /home/saojie/mysql-5.7.18
datadir = /home/saojie/mysql-5.7.18/data
log_error = /home/saojie/mysql-5.7.18/data/mysql_error.log
port = 33306    #Port avoidance conflict
socket = /home/saojie/mysql-5.7.18/mysql.sock
general_log = on
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

[mysql]
socket = /home/saojie/mysql-5.7.18/mysql.sock

Initialization

bin/mysqld --defaults-file=/home/saojie/mysql-5.7.18/my.cnf --initialize --user=saojie --basedir=/home/saojie/mysql-5.7.18/ --datadir=/home/saojie/mysql-5.7.18/data

Initialization generates a random password for root

start-up

For the first time, add socket to avoid connecting to someone else's MySQL Server, and because root does not have remote access by default, root cannot connect through the specified IP and port at the beginning

bin/mysqld --defaults-file=/home/saojie/mysql-5.7.18/my.cnf &

mysql -uroot -p --socket=/home/saojie/mysql-5.7.18/mysql.sock #You may connect to another MySQL Server without socket

Close

bin/mysqladmin -uroot -proot --socket=/home/saojie/mysql-5.7.18/mysql.sock shutdown
//or
bin/mysqladmin -hxxx -Pxxx -uroot -proot shutdown

Other questions

  • JDBC connection is slow

    Add skip name resolve under the configuration file [mysqld] and restart again to skip DNS query

  • Do not output MySQL logs to saojie user console

    Specify the log error address under [mysqld]

Convenient script

#!/bin/bash
function client(){
    bin/mysql --defaults-extra-file=/home/saojie/mysql-5.7.18/my.cnf
}

function server(){
    bin/mysqld --defaults-extra-file=/home/saojie/mysql-5.7.18/my.cnf  &
}

function stop(){
    bin/mysqladmin -uroot -p --socket=/home/saojie/mysql-5.7.18/mysql.sock shutdown
}

function pid(){

  ret=$(ps -ef |grep mysqld | awk '{print $2}')
    echo $ret
}

if [ $# = 1 ]; then $1; else server; fi

Posted by Shandrio on Mon, 04 Nov 2019 07:21:11 -0800