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

Mariadb-10.1.22mariadb compilation and installation

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

Official download address:

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

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

rpm -qa | grep mysql

Remove rm -rf /etc/my.cnf

2. Install dependency packages

# yum install -y libevent

# yum groupinstall -y Development Tools

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

Create database users and groups

#groupadd mysql

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

4. Create database data storage directory and grant permissions

#mkdir /appliction/mydata -p

#chown mysql.mysql /appliction/mydata -R

I. Compilation and installation start

1. Decompression

#tar zxf mariadb-10.1.22.tar.gz

#cd mariadb-10.1.22

#cmake . -DCMAKE_INSTALL_PREFIX=/application/mysql \ //install directory

-DMYSQL_DATADIR=/application/mydata \ //database directory

-DWITH_INNOBASE_STORAGE_ENGINE=1 \ //Support database innobase engine

-DWITH_ARCHIVE_STORAGE_ENGINE=1 \ //Support database archive engine

-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \ //Support 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

Perform compile installation:

cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data1/mysql -DSYSCONFDIR=/etc -DWITHOUT_TOKUDB=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STPRAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWIYH_READLINE=1 -DWIYH_SSL=system -DVITH_ZLIB=system -DWITH_LOBWRAP=0 -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci

Here's how: -DCMAKE_INSTALL_PREFIX is the specified installation location, here is/usr/local/mysql, -DMYSQL_DATADIR is the specified MySQL data directory, here is/data1/mysql, installation directory and data directory can be customized, -DSYSCONFDIR is the specified configuration file directory, generally/etc, the specific configuration file is/etc/my.cnf, -DWITOUT_TOKUDB=1 This parameter is generally set, indicating that tokudb engine is not installed, tokudb is an open source storage engine in MySQL, Can manage a large amount of data and some new features, these are not available Innodb, here is not installed, because the general computer default is no Percona Server, and loading tokudb also depends on jemalloc memory optimization, general development is not tokudb, so temporarily shielded, otherwise in the system can not find dependency will appear: CMake Error at storage/tokudb/PerconaFT/cmake_modules/TokuSetupCompilerNake:179 (message) such errors, and then those parameters are optional, you can add or not, the final code is recommended to set, so the compilation instructions can also be simplified as follows:

cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data1/mysql -DSYSCONFDIR=/etc -DWITHOUT_TOKUDB=1 -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci

Note: If there is an error in the execution, you can execute: rm -f CMakeCache.txt Delete the compilation cache and let the instruction re-execute. Otherwise, every time you read this file, the command is correct and the error is reported.

#make -j4

#make install

cmake no problem, can compile and install: make && make install takes a little long, wait patiently

Execution is complete, that is, the installation is complete. Now execute cd /usr/local/mysql/to enter the mysql installation directory and execute the following commands respectively:

chown -R mysql:mysql .

scripts/mysql_install_db --datadir=/data1/mysql --user=mysql

chown -R root .

cp support-files/mysql.server /etc/init.d/mysqld

You can then add mysqld to the system service as well:

chkconfig --add mysqld #Add to System Services

chkconfig mysqld on #Set boot to boot

If you start now, you may report an error because the log directory has not been established. The default is/var/log/mariadb/mariadb.log, which can also be modified later. Now execute: mkdir/var/log/mariadb to establish the log directory, and then execute: /etc/init.d/mysqld start or systemctl start mysqld.service to start mysql service.

After starting the service, you cannot enter the mysql shell interface immediately. The reason is that the local socket executed during compilation is: /tmp/mysql.sock, but the location configured in/etc/my.cnf is: /var/lib/mysql/mysql.sock. Now execute the command: ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock to establish a soft link.

2. Configure MariaDB

#cd /appliction/mysql

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

Copy configuration file

#cd /appliction/mysql/support-files/

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

Create startup script

# cd /appliction/mysql/support-files/

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

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

start the database

# /etc/rc.d/init.d/mysqld start Login database, no password required

The requested URL/tmp/mysql.sock was not found on this server.

# mysql

qld start

Reloading systemd: [ OK ]

Starting mysqld (via systemctl): [ OK ]

Initialize the database, this way you can disable the empty password login, follow the prompts to enter the Y or N you need

# mysql_secure_installation

Set mysql local mode password free login

# egrep -v "^$|#" /etc/my.cnf

[client]

port= 3306

socket= /tmp/mysql.sock

[mysqld]

port= 3306

socket= /tmp/mysql.sock

basedir=/usr/local/mysql (installation database directory)

datadir=/home/mydata

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

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