Install MySQL from Source code

Compile and Install

Preconfiguration Setup

Create user and group
$ sudo groupadd mysql
$ sudo useradd -r -g mysql mysql
Extract tar.gz
$ tar xf mysql-5.7.3-m13.tar.gz
$ cd mysql-5.7.3-m13

Compile and Install

$ cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
> -DDEFAULT_CHARSET=gbk \
> -DDEFAULT_COLLATION=gbk_chinese_ci \
> -DENABLED_LOCAL_INFILE=ON \
> -DWITH_INNOBASE_STORAGE_ENGINE=1 \
> -DWITH_FEDERATED_STORAGE_ENGINE=1 \
> -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
> -DMYSQL_UNIX_ADDR=/tmp/mysqld.sock \
> -DWITH_DEBUG=0 \
> -DMYSQL_TCP_PORT=3306
$ make
$ sudo make install
cmake logs

Configuration and Initial

Permission Manager

$ sudo chown -R mysql:mysql /usr/local/mysql

Initial MySQL

$ scripts/mysql_install_db --user=mysql
$ cp support-files/mysql.server /etc/init.d/mysqld
Log of mysql_install_db --user=mysql

Change Permission again

$ sudo chown -R root .
$ sudo chown -R mysql data

Start mysqld_safe

$ sudo bin/mysqld_safe --user=mysql &

Setup root password

$ sudo ./bin/mysqladmin -u root password '<PASSWORDHERE>'
# Or
$ sudo ./bin/mysql_secure_installation
Log of mysql_secure_installatioin

Set Environment

$ sudo bash -c 'cat >> /etc/bash.bashrc' << EOF
> export PATH=/usr/local/mysql/bin:$PATH
> EOF

Check the mysql port

$ sudo netstat -tunlp  | grep 3306
tcp6       0      0 :::3306                 :::*                    LISTEN      21712/mysqld

Check variables

$ mysqladmin variables -p
Enter password:

Make mysql as boot start

$ sudo chkconfig --add mysqld
$ sudo chkconfig --level 345 mysqld on
Copyright © marslo 2020-2023 all right reserved,powered by GitbookLast Modified: 2024-03-12 15:01:28

results matching ""

    No results matching ""