Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Install mariadb5.5 in binary mode on centos6

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report