溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

Centos7 MariaDB10.1.22編譯安裝

發(fā)布時間:2020-07-02 00:25:07 來源:網(wǎng)絡(luò) 閱讀:974 作者:一招拜師 欄目:數(shù)據(jù)庫

當(dāng)前系統(tǒng)環(huán)境

# 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) 

#----------------------------------分隔符---------------------------------------------#

#----------------------------------分隔符---------------------------------------------#

官方下載地址: 

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

#----------------------------------分隔符---------------------------------------------#

#----------------------------------分隔符---------------------------------------------#

1、首先查詢下是否安裝了mysql或者舊版本mariadb

rpm -qa | grep mysql

刪除rm -rf /etc/my.cnf

#----------------------------------分隔符---------------------------------------------#

#----------------------------------分隔符---------------------------------------------#

2、安裝依賴包

#  yum install  -y  libevent 

# yum groupinstall -y Development Tools

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

#----------------------------------分隔符---------------------------------------------#

#----------------------------------分隔符---------------------------------------------#

3、創(chuàng)建數(shù)據(jù)庫用戶及組

#groupadd mysql

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

#----------------------------------分隔符---------------------------------------------#

#----------------------------------分隔符---------------------------------------------#

4、創(chuàng)建數(shù)據(jù)庫數(shù)據(jù)存放目錄及賦予權(quán)限

#mkdir /appliction/mydata -p

#chown mysql.mysql /appliction/mydata -R

#----------------------------------分隔符---------------------------------------------#

#----------------------------------分隔符---------------------------------------------#

一、編譯安裝開始

1、解壓

#tar zxf mariadb-10.1.22.tar.gz

#cd mariadb-10.1.22

#cmake . -DCMAKE_INSTALL_PREFIX=/appliction/mysql \      //安裝目錄

          -DMYSQL_DATADIR=/appliction/mydata \      //數(shù)據(jù)庫存放目錄

          -DWITH_INNOBASE_STORAGE_ENGINE=1 \       //支持?jǐn)?shù)據(jù)庫innobase引擎

          -DWITH_ARCHIVE_STORAGE_ENGINE=1 \       //支持?jǐn)?shù)據(jù)庫archive引擎

          -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \     //支持?jǐn)?shù)據(jù)庫blackhole存儲引擎

          -DWITH_READLINE=1 \                                    

          -DWITH_SSL=system \                                    

          -DWITH_ZLIB=system \

          -DWITH_LIBWRAP=0 \

          -DMYSQL_UNIX_ADDR=/tmp/mysql.sock \                   

          -DDEFAULT_CHARSET=utf8 \             //字符集utf8

          -DDEFAULT_COLLATION=utf8_general_ci \    //校驗(yàn)字符

          -DENABLED_LOCAL_INFILE=1             //允許本地導(dǎo)入數(shù)據(jù)  


       

#----------------------------------分隔符---------------------------------------------#

#----------------------------------分隔符---------------------------------------------#

#make -j4

#make install

#----------------------------------分隔符---------------------------------------------#

#----------------------------------分隔符---------------------------------------------#

2、配置MariaDB

#cd /appliction/mysql

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

#ls /appliction/mydata  (此目錄原是空目錄)

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


#----------------------------------分隔符---------------------------------------------#

#----------------------------------分隔符---------------------------------------------#

3、刪除my.cnf

# rm -rf /etc/my.cnf

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

#----------------------------------分隔符---------------------------------------------#

#----------------------------------分隔符---------------------------------------------#

4、復(fù)制配置文檔

#cd /appliction/mysql/support-files/

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

#----------------------------------分隔符---------------------------------------------#

#----------------------------------分隔符---------------------------------------------#

4、創(chuàng)建啟動腳本

# cd /appliction/mysql/support-files/

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

#----------------------------------分隔符---------------------------------------------#

#----------------------------------分隔符---------------------------------------------#

5、配置環(huán)境變量,方便直接輸入mysql

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

MYSQL_HOME=/appliction/mysql

export PATH=$MYSQL_HOME/bin:$PATH

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

#----------------------------------分隔符---------------------------------------------#

#----------------------------------分隔符---------------------------------------------#

6、啟動數(shù)據(jù)庫

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

Reloading systemd:               [  OK  ]

Starting mysqld (via systemctl):      [  OK  ]

#----------------------------------分隔符---------------------------------------------#

#----------------------------------分隔符---------------------------------------------#

7、登陸數(shù)據(jù)庫,不需要密碼

# 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)]>

#----------------------------------分隔符---------------------------------------------#

#----------------------------------分隔符---------------------------------------------#

8、初始化數(shù)據(jù)庫,此方式可以禁用空密碼登陸,按照提示輸入你需要的Y或者N

# 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.

#輸入當(dāng)前root賬號數(shù)據(jù)庫密碼,現(xiàn)在為空

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.

#設(shè)置root密碼

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.

#是否移除匿名用戶

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.

#是否禁止root用戶遠(yuǎn)程登陸

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.

#是否移除test數(shù)據(jù)庫

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.

#是否現(xiàn)在重新加載授權(quán)信息

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!

#----------------------------------分隔符---------------------------------------------#

#----------------------------------分隔符---------------------------------------------#

9、設(shè)置mysql本地方式免密碼登陸

# egrep -v "^$|#" /etc/my.cnf  (增加了紅色部分

[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

#----------------------------------分隔符---------------------------------------------#

#----------------------------------分隔符---------------------------------------------#

#----------------------------------分隔符---------------------------------------------#

#----------------------------------分隔符---------------------------------------------#

注意事項(xiàng):

若是重新安裝需要make clean 及 rm CMAKECache.txt

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI