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


Linux Generic


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


Write profile

Put my.cnf in mysql-5.7.18

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

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


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


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


bin/mysqladmin -uroot -proot --socket=/home/saojie/mysql-5.7.18/mysql.sock shutdown
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

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