1. 程式人生 > >linux服務基礎之CentOS6編譯安裝mariadb

linux服務基礎之CentOS6編譯安裝mariadb

lvcreate 文件格式 release spa dir 初始 config oot rc.d

1. 下載mariadb

https://downloads.mariadb.org/mariadb/+releases/

2. 解壓到指定目錄

# tar xf mariadb-5.5.43-linux-x86_64.tar.gz -C /usr/local

# cd /usr/local
# ln -sv mariadb-5.5.43-linux-x86_64/ mysql

# groupadd -r mysql
# useradd -r -g mysql mysql
# cd mysql
# chown -R :mysql ./*

3. 使用xfs文件格式存放mariadb數據

# pvcreate /dev/sdb1
# vgcreate myvg 
/dev/sdb1 # lvcreate -L 6G -n mylv myvg  //創建邏輯卷
# yum install xfsprogs # modprobe xfs # mkfs.xfs
/dev/myvg/mylv  //格式化文件格式

# vim /etc/fstab     添加:
/dev/myvg/mylv /mydata xfs defaults 0 0  //開機掛載  # mount -a

# mkdir /mydata/data  //用於存放mysql數據
# chown /mydata/data

4. 配置

# scripts/mysql_install_db --user=mysql --datadir=/mydata/data  //安裝mysql元數據的數據庫
# cp support-files/mysql.server /etc/rc.d/init.d/mysqld  //添加mysql服務腳本
# chkconfig --add mysqld
# mkdir /etc/mysql
# cp support-files/my-large.cnf /etc/mysql/my.cnf  //添加配置文件
        添加三個選項
                   datadir= /mydata/data
                   innodb_file_per_table = on 
                   skip_name_resolve 
= on
# ln /usr/local/mysql/bin/mysql /usr/bin  //添加客戶端執行程序

5. 運行mysql

# service mysqld start
# mysql    //登錄mysql
    > USE mysql
    > SELECT User,Host,Passwrod from user;
    > exit

5. 執行mysql安全初始化程序

# /usr/local/mysql/bin/mysql_secure_installation   //添加root賬號,刪除匿名用戶等

6.登錄mysql

# mysql -uroot -palen

linux服務基礎之CentOS6編譯安裝mariadb