Get the App
SLTechnology News&Howtos  ›  Database  › 

RedHat compilation and installation of MySQL

Shulou Source: shulou.com Published: 2022-06-01 09:56:40 10月30日 Update

1. Download mysql source package and rpm package of cmake:

boost_1_59_0.tar.gz

mysql-5.7.19.tar.gz

cmake-2.8.12.2-4.el6.x86_64.rpm

2. Decompress the compressed package and move it to the corresponding position (not fixed):

cp -rf boost_1_59_0 /usr/local/boost

cp -rf mysql-5.7.19 /usr/local/mysql

Creating Users and Groups:

groupadd mysql

useradd -g mysql mysql

4. Install the compilation environment dependency package (configure yum and mount it):

yum install gcc gcc-c++ -y

yum install -y ncurses-devel.x86_64

yum install -y cmake.x86_64

yum install -y libaio.x86_64

yum install -y bison.x86_64

yum install -y gcc-c++.x86_64

5. Install cmake:

yum -y localinstall cmake-2.8.12.2-4.el6.x86_64.rpm

6. Create a directory:

mkdir -p /home/mysql3306/mysql3306

mkdir -p /home/mysql3306/logs

Assign permissions to directories:

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

chown -R mysql:mysql /home/mysql3306

7. Compile and install MySQL in the installation directory:

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/home/mysql3306/mysql3306 -DDEFAULT_CHARSET=utf8 -DEXTRA_CHARSETS=all -DSYSCONFDIR=/etc -DENABLED_LOCAL_INFILE=1 -DMYSQL_UNIX_ADDR=/tmp/mysql.sock-DDEFAULT_COLLATION=utf8_general_ci -DMYSQL_TCP_PORT=3306 -DMYSQL_USER=mysql -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_BOOST=/usr/local/boost

8. Execute after completion: make && make install

9. Add mysql.server to the service (varies from person to person, not required):

cd /usr/local/mysql/support-files

cp mysql.server /etc/init.d/mysqld

chmod 755 /etc/init.d/mysqld

10. Configure MySQL's configuration file my.cnf(the configuration file here is too simple and can be added as needed):

#vim /etc/my.cnf

[mysqld]

basedir = /usr/local/mysql

datadir = /home/mysql3306/mysql3306

port = 3306

#character utf8

character_set_server=utf8

init_connect='SET NAMES utf8'

[client]

default-character-set=utf8

socket=/tmp/mysql.sock

Initialize MySQL (note the initialization command for version 5.7):

/usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf --initialize-insecure --basedir=/usr/local/mysql --datadir=/home/mysql3306/mysql3306/ --user=mysql

Start MySQL service: service mysqld start

13. Enter MySQL initialization permissions and modify the password for root. Because the--initialize-insecure parameter is added during initialization, you can log in without secret. If you don't add it, the default password will be generated in the error log.

Tags: Configuration directory compilation password file service vary from person to person location parameters commands permissions source code version environment user empowerment middle student login mobile Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info MySQL Shulou Information Linux macOS