Get the App
SLTechnology News&Howtos  ›  Database  › 

Install mariadb5.5 in binary mode on centos6

Shulou Source: shulou.com Published: 2022-06-01 10:15:33 09月28日 Update

Prepare the mariadb-5.5.57-linux-x86_ 64.tar.gz binary package

This package is compiled, which means we have to install it in a specific directory

Step 1. Prepare mysql users

Mkdir / app/data

# this directory stores mysql databases and tables

Useradd-r-m-d / app/data-s / sbin/nologin mysql

# create mysql users, and many operations are performed as mysql users

Step 2. Prepare the binaries

Tar-xvf mariadb-5.5.57-linux-x86_64.tar.gz-C / usr/local/

# extract the binary package to the specified directory / usr/local

# this directory is fixed at compile time and must be in this directory

Cd / usr/local/

Mv mariadb-5.5.57-linux-x86_64/ mysql

# it is also booked in advance, and the directory name must also be mysql

Step 3. Edit the configuration file

Mkdir / etc/mysql

Cp / usr/local/mysql/support-files/my-large.cnf / etc/mysql/my.cnf

# We need to modify the configuration file of mysql, just copy the template and modify it

Vim / etc/mysql/my.cnf

# The MariaDB server

[mysqld]

Datadir = / app/data / / specify the path where the data is stored

Innodb_file_per_table = on

Skip_name_resolve = on

# add the above three lines, the most important is the first line

# at this time / app/data does not have any data files

Step 4. Create the system database mysql

Cd / usr/local/mysql/

. / scripts/mysql_install_db-datadir=/app/data-user=mysql

# create database files, and also create files such as test test database, so there are many files under / app/data

Step 5. Add a mysql service

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

# copy the service script of mysql to the directory loaded by the system startup, and this script will be loaded to enable the mysql service when the system starts

Chkconfig-add mysqld

Chkconfig mysqld on

# set mysqld to boot automatically

Step 6. Start mysqld

Service mysqld start

# starting the service at this time will prompt a failure message because the log file does not specify permissions

# the path to the log file specified in the / etc/my.cnf file, namely log-error=/var/log/mysqld.log

# so we need to make sure that this file exists and that mysql has read and write access to it

Touch / var/log/mysqld.log

Setfacl-m u:mysql:rw / var/log/mysqld.log

Service mysqld start

# start the service again at this time to be successful

# although the service can be started, mysql still cannot be used, indicating that there is no such command

# the reason is that the command of mysql is not specified in the global variable PATH

Vim / etc/profile.d/mysql.sh

MYSQL_HOME=/usr/local/mysql/bin/

Export PATH=$MYSQL_HOME:$PATH

. / etc/profile.d/mysql.sh / / remember to make it effective after modification

# now you can use mysql

You may wonder, what's the difference between / etc/mysql/my.cnf and / etc/my.cnf?

In fact, both of them are mysql configuration files, but the order of execution is different. Execute / etc/my.cnf before / etc/mysql/my.cnf.

That is to say, the latter takes precedence over the former, so we modify the configuration information under / etc/mysql/my.cnf

As for the log file, since only the / etc/my.cnf file is defined, there is no need to configure it again in / etc/mysql/my.cnf

Step 7. Initialize the database securely

/ usr/local/mysql/bin/mysql_secure_installation / / because mysql has just been installed and does not have any security policy, any anonymous user can log in, so there is a security risk

# set root password for database administrator

# disable root remote login

# Delete anonymous user account

# Delete test database

These are all the steps to install mariadb in binary mode, over!

Tags: Files data steps databases directories services users configuration binaries security logs systems preparation that is information commands permissions scripts paths Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Apple Redmi NVidia Docker