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

Detailed explanation of Linux installation and configuration MariaDB database

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

MariaDB is stronger than MySQL in many aspects. How to install MariaDB database under Linux has become a headache for everyone. Let's explain it with an example.

MariaDB is the MySQL branch version of the Maria storage engine, which is stronger than MySQL in many ways, so how to install the MariaDB database under Linux? The following editor will introduce to you the method of Linux installation and configuration of MariaDB database.

Description:

Operating system: CentOS 5.10 32-bit

MariaDB version: mariadb-5.5.33a

MariaDB database storage directory: / data/mysql

Preparation:

First, configure IP, DNS and gateway to ensure that you can connect to the server using the remote connection tool, and the server yum command can be used normally.

Configure the firewall and open port 3306

Vi / etc/sysconfig/iptables # editing

-A RH-Firewall-1-INPUT-m state-- state NEW-m tcp-p tcp-- dport 3306-j ACCEPT # allow port 3306 to pass through the firewall

Special note: many netizens add these two rules to the last line of the firewall configuration, causing the firewall to fail to start, and the correct one should be added to the default port 22 rule.

After being added, the firewall rules are as follows:

*

# Firewall configuration written by system-config-securitylevel

# Manual customization of this file is not recommended.

* filter

: INPUT ACCEPT [0:0]

: FORWARD ACCEPT [0:0]

: OUTPUT ACCEPT [0:0]

: RH-Firewall-1-INPUT-[0:0]

-An INPUT-j RH-Firewall-1-INPUT

-A FORWARD-j RH-Firewall-1-INPUT

-A RH-Firewall-1-INPUT-I lo-j ACCEPT

-A RH-Firewall-1-INPUT-p icmp--icmp-type any-j ACCEPT

-A RH-Firewall-1-INPUT-p 50-j ACCEPT

-A RH-Firewall-1-INPUT-p 51-j ACCEPT

-A RH-Firewall-1-INPUT-p udp-- dport 5353-d 224.0.0.251-j ACCEPT

-A RH-Firewall-1-INPUT-p udp-m udp-- dport 631-j ACCEPT

-A RH-Firewall-1-INPUT-p tcp-m tcp-- dport 631-j ACCEPT

-A RH-Firewall-1-INPUT-m state-- state ESTABLISHED,RELATED-j ACCEPT

-A RH-Firewall-1-INPUT-m state-- state NEW-m tcp-p tcp-- dport 22-j ACCEPT

-A RH-Firewall-1-INPUT-m state-- state NEW-m tcp-p tcp-- dport 3306-j ACCEPT

-A RH-Firewall-1-INPUT-j REJECT-- reject-with icmp-host-prohibited

COMMIT

*

/ etc/init.d/iptables restart # finally restart the firewall for the configuration to take effect

3. Close SELINUX

Vi / etc/selinux/config

# SELINUX=enforcing # comment out

# SELINUXTYPE=targeted # comment out

SELINUX=disabled # increased

: wq! # Save exit

Shutdown-r now # restart the system

IV. System agreement

MariaDB installation package location: / usr/local/src

MariaDB compilation installation location: / usr/local/mysql

Download the software package

1. Download MariaDB

Http://mirrors.scie.in/mariadb/mariadb-5.5.33a/kvm-tarbake-jaunty-x86/mariadb-5.5.33a.tar.gz

2. Download cmake (MariaDB compilation tool)

Http://www.cmake.org/files/v2.8/cmake-2.8.12.1.tar.gz

Download the above two software and upload them to the / usr/local/src directory

6. Install compilation tools and library files (use CentOS yum command to install, install more, facilitate later compilation and installation of php, nginx, etc.)

Yum install make apr* autoconf automake curl curl-devel gcc gcc-c++ gtk+-devel zlib-devel openssl openssl-devel pcre-devel gd kernel keyutils patch perl kernel-headers compat* cpp glibc libgomp libstdc++-devel keyutils-libs-devel libsepol-devel libselinux-devel krb5-devel libXpm* freetype freetype-devel freetype* fontconfig fontconfig-devel libjpeg* libpng* php-common php-gd gettext gettext-devel ncurses* libtool* libxml2 libxml2-devel patch policycoreutils bison

Installation section

First, install cmake

Cd / usr/local/src

Tar zxvf cmake-2.8.12.1.tar.gz

Cd cmake-2.8.12.1

. / configure

Make # compilation

Make install # installation

Second, install MariaDB

Groupadd mysql # add MariaDB database installation user group mysql

Useradd-g mysql mysql-s / bin/false # create a user mysql and join the mysql group, and do not allow mysql users to log in directly to the system

Mkdir-p / data/mysql # create MariaDB database storage directory

Chown-R mysql:mysql / data/mysql # set MariaDB database directory permissions

Mkdir-p / usr/local/mysql # create the MariaDB installation directory

Cd / usr/local/src

Tar zxvf mariadb-5.5.33a.tar.gz # decompression

Cd mariadb-5.5.33a # enter the installation directory

Cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql-DMYSQL_DATADIR=/data/mysql-DSYSCONFDIR=/etc

# configuration

Make # compilation

Make install # installation

Cd / usr/local/mysql

Cp . / support-files/my-huge.cnf / etc/my.cnf # copy the configuration file (Note: if there is a my.cnf by default under the / etc directory, you can overwrite it directly)

Vi / etc/my.cnf # edit the configuration file and add it in the [mysqld] section

Datadir = / data/mysql # add MariaDB database path

. / scripts/mysql_install_db-- user=mysql # generate MariaDB system database

Cp . / support-files/mysql.server / etc/rc.d/init.d/mysqld # add MariaDB to the system startup

Chmod 755 / etc/init.d/mysqld # increased execution permissions

Chkconfig mysqld on # join Boot Boot

Vi / etc/rc.d/init.d/mysqld # editing

Basedir = / usr/local/mysql # MariaDB program installation path

Datadir = / data/mysql # MariaDB database storage directory

Service mysqld start # Startup

Vi / etc/profile # adds the MariaDB service to the system environment variable: add the following line at the end

Export PATH=$PATH:/usr/local/mysql/bin

The following two lines link the library files of MariaDB to the default location of the system, so that you don't have to specify the library file address of MariaDB when compiling software like PHP.

Ln-s / usr/local/mysql/lib/mysql / usr/lib/mysql

Ln-s / usr/local/mysql/include/mysql / usr/include/mysql

Shutdown-r now # needs to restart the system and continue to operate under the terminal command line after waiting for the system to restart

Mysql_secure_installation # set the MariaDB database root account password

Press enter Y to enter the password twice according to the prompt

Or change the password directly / usr/local/mysql/bin/mysqladmin-u root-p password "123456" # change the password

Service mysqld restart # restart

Mysql-u root-p # enter the root password set above to log in to the mariadb console, as shown in the following figure:

At this point, the MariaDB database installation is complete!

The above is the introduction of Linux installation and configuration of MariaDB database steps, based on the many advantages of MariaDB database, I believe that many people will choose to use MariaDB database, for friends who do not know how to install MariaDB database, I hope the introduction of this article will be helpful to you.

Quick installation of MariaDB under linux

MariaDB is a branch version of MySQL that uses the Maria storage engine. It is a free and open source database server developed by the company founded by Michael Widenius, the author of the original MySQL.

This article introduces a simple installation method under linxu (successfully tested under OpenSuse):

Download page: https://downloads.mariadb.org/mariadb/5.5.34/

# tar zxvf mariadb-5.5.31-linux-x86_64.tar.gz

# mv mariadb-5.5.31-linux-x86_64 / usr/local/mysql (required, many scripts or executables will access this directory directly)

# groupadd mysql adds mysql group

# useradd-g mysql mysql increases mysql users and belongs to mysql group

# chown mysql:mysql-Rf / usr/local/mysql sets the user and user group ownership of the mysql directory.

# chmod + x-Rf / usr/local/mysql Grant executable permission

# cp / usr/local/mysql/support-files/my-medium.cnf / etc/my.cnf copy the default mysql configuration file to the / etc directory

# / usr/local/mysql/scripts/mysql_install_db-- user=mysql initializes the database

# cp / usr/local/mysql/support-files/mysql.server / etc/init.d/mysql copy the mysql service program to the system directory

# chkconfig mysql on add mysql to the system service and set it to boot

# service mysql start starts mysql

# vim / etc/profile Editing profile, adding the executable path of mysql to the system PATH

Export PATH=/usr/local/mysql/bin:$PATH

# source / etc/profile makes PATH effective.

# mysqladmin-u rootpassword' yourrootpassword' configure root account and password

# mysql-uroot-p Log in to mysql using the root user

[none] > use mysql switch to mysql database.

[mysql] > select user,host,password from user;-- View system permissions

[mysql] > drop user'@ 'localhost';-Delete unsecured accounts

[mysql] > drop user root@'::1'

[mysql] > drop user root@127.0.0.1

. . .

[mysql] > select user,host,password from user;-check the system permissions again to make sure that insecure accounts are deleted.

[mysql] > flush privileges;-- refresh permissions

1) modify the character set to UTF8

# vi / etc/my.cnf

Add default-character-set = utf8 under [client]

Add character_set_server = utf8 under [mysqld]

Restart after modification: # service mysql restart

2) add error log

# vi / etc/my.cnf

Add under [mysqld]:

Log-error = / usr/local/mysql/log/error.log

General-log-file = / usr/local/mysql/log/mysql.log

Restart after modification: # service mysql restart

3) set to case-insensitive, and the default in linux will be case-sensitive.

# vi / etc/my.cnf

Add under [mysqld]:

Lower_case_table_name=1

Restart after modification: # service mysql restart

=

The above is reproduced and is suitable for the system before linux uses systemctl. Here is the installation method for using systemctl system. At the same time, reference the official installation method of mariadb.

Https://mariadb.com/kb/en/mariadb/installing-mariadb-binary-tarballs/

Only the root installation method is referenced here, because this method is the most commonly used, and others can be learned through the link above

Groupadd mysql

Useradd-g mysql mysql

Cd / usr/local

Tar-zxvpf / path-to/mariadb-VERSION-OS.tar.gz

Ln-s mariadb-VERSION-OS mysql

Cd mysql

. / scripts/mysql_install_db-- user=mysql

Chown-R root.

Chgrp-R root.

Chown-R mysql data

Chgrp-R mysql data

Cp support-files/mysql.server / etc/init.d/mysql.server

After creating the startup file / etc/systemd/system/mysql.service to be used by systemctl

[Unit]

Description=MySQL Server

After=network.target

[Service]

Type=forking

ExecStart=/etc/init.d/mysql.server start

ExecStop=/etc/init.d/mysql.server stop

[Install]

WantedBy=multi-user.target

# systemctl start mysql.service command can start mysql

Systemctl can view this reprinted article and write it more clearly. (view)

Open a remote connection:

GRANT ALL PRIVILEGES ON *. * TO 'root'@'%' IDENTIFIED BY' mypassword' WITH GRANT OPTION

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

Database

Wechat

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

12
Report