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

Centos7 MariaDB10.1.22 compilation and installation

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

Share

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

Current system environment

# hostnamectl

Static hostname: localhost.localdomain

Icon name: computer-vm

Chassis: vm

Machine ID: 2db9c42fe2974c44a4d53161c3cd9fb4

Boot ID: b9a685bd7d9e47eaaa5a742712c930ac

Virtualization: vmware

Operating System: CentOS Linux 7 (Core)

CPE OS Name: cpe:/o:centos:centos:7

Kernel: Linux 3.10.0-514.10.2.el7.x86_64

Architecture: x86-64

# cat / etc/redhat-release

CentOS Linux release 7.3.1611 (Core)

#-delimiter-#

#-delimiter-#

Official download address:

Https://mirrors.tuna.tsinghua.edu.cn/mariadb//mariadb-10.1.22/source/mariadb-10.1.22.tar.gz

#-delimiter-#

#-delimiter-#

1. First query whether mysql or the old version of mariadb is installed.

Rpm-qa | grep mysql

Delete rm-rf / etc/my.cnf

#-delimiter-#

#-delimiter-#

2. Install the dependency package

# yum install-y libevent

# yum groupinstall-y Development Tools

# yum install-y ncurses-devel openssl-devel openssl

#-delimiter-#

#-delimiter-#

3. Create database users and groups

# groupadd mysql

# useradd mysql-s / sbin/nologin-g mysql-M mysql

#-delimiter-#

#-delimiter-#

4. Create a database data storage directory and grant permissions

# mkdir / appliction/mydata-p

# chown mysql.mysql / appliction/mydata-R

#-delimiter-#

#-delimiter-#

I. compilation and installation begins

1. Decompression

# tar zxf mariadb-10.1.22.tar.gz

# cd mariadb-10.1.22

# cmake. -DCMAKE_INSTALL_PREFIX=/appliction/mysql\ / / installation directory

-DMYSQL_DATADIR=/appliction/mydata\ / / Database storage directory

-DWITH_INNOBASE_STORAGE_ENGINE=1\ / / supports database innobase engine

-DWITH_ARCHIVE_STORAGE_ENGINE=1\ / / supports database archive engine

-DWITH_BLACKHOLE_STORAGE_ENGINE=1\ / / supports database blackhole storage engine

-DWITH_READLINE=1\

-DWITH_SSL=system\

-DWITH_ZLIB=system\

-DWITH_LIBWRAP=0\

-DMYSQL_UNIX_ADDR=/tmp/mysql.sock\

-DDEFAULT_CHARSET=utf8\ / / character set utf8

-DDEFAULT_COLLATION=utf8_general_ci\ / / check character

-DENABLED_LOCAL_INFILE=1 / / allow local import of data

#-delimiter-#

#-delimiter-#

# make-j4

# make install

#-delimiter-#

#-delimiter-#

2. Configure MariaDB

# cd / appliction/mysql

# scripts/mysql_install_db-user=mysql-datadir=/appliction/mydata

# ls / appliction/mydata (this directory was originally empty)

Total 110616

16-rw-rw----. 1 mysql mysql 16384 Mar 27 16:17 aria_log.00000001

4-rw-rw----. 1 mysql mysql 52 Mar 27 16:17 aria_log_control

12288-rw-rw----. 1 mysql mysql 12582912 Mar 27 16:17 ibdata1

49152-rw-rw----. 1 mysql mysql 50331648 Mar 27 16:17 ib_logfile0

49152-rw-rw----. 1 mysql mysql 50331648 Mar 27 16:17 ib_logfile1

4 drwx-. 2 mysql root 4096 Mar 27 16:17 mysql

0 drwx-. 2 mysql mysql 20 Mar 27 16:17 performance_schema

0 drwx-. 2 mysql root 6 Mar 27 16:17 test

#-delimiter-#

#-delimiter-#

3. Delete my.cnf

# rm-rf / etc/my.cnf

# rm-rf / etc/my.cnf.d

#-delimiter-#

#-delimiter-#

4. Copy the configuration document

# cd / appliction/mysql/support-files/

# cp my-large.cnf / etc/my.cnf

#-delimiter-#

#-delimiter-#

4. Create a startup script

# cd / appliction/mysql/support-files/

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

#-delimiter-#

#-delimiter-#

5. Configure environment variables to facilitate direct input of mysql

# cat / etc/profile.d/mysql.sh

MYSQL_HOME=/appliction/mysql

Export PATH=$MYSQL_HOME/bin:$PATH

# source / etc/profile.d/mysql.sh

#-delimiter-#

#-delimiter-#

6. Start the database

# / etc/rc.d/init.d/mysqld start

Reloading systemd: [OK]

Starting mysqld (via systemctl): [OK]

#-delimiter-#

#-delimiter-#

7. Log in to the database without a password

# mysql

Welcome to the MariaDB monitor. Commands end with; or\ g.

Your MariaDB connection id is 4

Server version: 10.1.22-MariaDB Source distribution

Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or'\ h' for help. Type'\ c'to clear the current input statement.

MariaDB [(none)] >

#-delimiter-#

#-delimiter-#

8. Initialize the database. In this way, you can disable login with an empty password and follow the prompts to enter the Y or N you need.

# mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB

SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current

Password for the root user. If you've just installed MariaDB, and

You haven't set the root password yet, the password will be blank

So you should just press enter here.

# enter the database password for the current root account, which is now empty

Enter current password for root (enter for none):

OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB

Root user without the proper authorisation.

# set root password

Set root password? [Y/n] y

New password:

Re-enter new password:

Password updated successfully!

Reloading privilege tables..

... Success!

By default, a MariaDB installation has an anonymous user, allowing anyone

To log into MariaDB without having to have a user account created for

Them. This is intended only for testing, and to make the installation

Go a bit smoother. You should remove them before moving into a

Production environment.

# whether to remove anonymous users

Remove anonymous users? [Y/n] y

... Success!

Normally, root should only be allowed to connect from 'localhost'. This

Ensures that someone cannot guess at the root password from the network.

# whether to prohibit root users from logging in remotely

Disallow root login remotely? [Y/n] y

... Success!

By default, MariaDB comes with a database named 'test' that anyone can

Access. This is also intended only for testing, and should be removed

Before moving into a production environment.

# whether to remove test database

Remove test database and access to it? [Y/n] y

-Dropping test database...

... Success!

-Removing privileges on test database...

... Success!

Reloading the privilege tables will ensure that all changes made so far

Will take effect immediately.

# whether to reload authorization information now

Reload privilege tables now? [Y/n] Y

... Success!

Cleaning up...

All done! If you've completed all of the above steps, your MariaDB

Installation should now be secure.

Thanks for using MariaDB!

#-delimiter-#

#-delimiter-#

9. Set mysql local mode to log in without password

# egrep-v "^ $| #" / etc/my.cnf (red part added)

[client]

Port= 3306

Socket= / tmp/mysql.sock

[mysqld]

Port= 3306

Socket= / tmp/mysql.sock

Skip-external-locking

Key_buffer_size = 256m

Max_allowed_packet = 1m

Table_open_cache = 256

Sort_buffer_size = 1m

Read_buffer_size = 1m

Read_rnd_buffer_size = 4m

Myisam_sort_buffer_size = 64m

Thread_cache_size = 8

Query_cache_size= 16M

Thread_concurrency = 8

Log-bin=mysql-bin

Binlog_format=mixed

Server-id= 1

[mysqldump]

Quick

Max_allowed_packet = 16m

[mysql]

No-auto-rehash

User = root

Password = 123456

Host = 127.0.0.1

[myisamchk]

Key_buffer_size = 128m

Sort_buffer_size = 128m

Read_buffer = 2m

Write_buffer = 2m

[mysqlhotcopy]

Interactive-timeout

#-delimiter-#

#-delimiter-#

#-delimiter-#

#-delimiter-#

Note:

Make clean and rm CMAKECache.txt are required for reinstallation

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