CentOS 6.6下編譯安裝MariaDB-10.0.24
系統環境:CentOS 6.7(Final)
MariaDB埠:3309 (因為本機原先已經裝的有MySQL了,不想刪除MySQL)
#wget
# wget -O
建立mariadb使用者
# groupadd -r mariadb
# useradd -g mariadb -r -M -s /sbin/nologin mariadb //禁止mariadb使用者本地登入
依賴元件
# yum -y install gcc gcc-c++ make cmake ncurses ncurses-devel libxml2 libxml2-devel openssl-devel bison bison-devel
# tar -zxvf mariadb-10.0.24.tar.gz
# cd mariadb-10.0.24
# cmake . -DMYSQL_UNIX_ADDR=/tmp/mariadb.sock -DSYSCONFDIR=/usr/local/mariadb -DMYSQL_TCP_PORT=3309 -DEXTRA_CHARSETS=all -DMYSQL_USER=mariadb -DCMAKE_INSTALL_PREFIX=/usr/local/mariadb -DMYSQL_DATADIR=/data/mariadb -DWITH_XTRADB_STORAGE_ENGINE=1 -DWITH_FEDERATEDX_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_MYISAM_STORAGE_ENGINE=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 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci
# make -j 4 && make install
把MariaDB服務加入系統環境變數:在最後新增下面這一行
# vim /etc/profile
export PATH=/usr/local/mariadb/bin:$PATH
# source /etc/profile
複製配置檔案
# cp /usr/local/mariadb/support-files/my-large.cnf /usr/local/mariadb/my.cnf
初始化資料庫
# /usr/local/mariadb/scripts/mysql_install_db --basedir=/usr/local/mariadb --datadir=/data/mariadb --user=mariadb --defaults-file=/usr/local/mariadb/my.cnf
複製服務啟動指令碼
# cp /usr/local/mariadb/support-files/mysql.server /etc/init.d/mariadb
# vim /etc/init.d/mariadb
找到
$bindir/mysqld_safe --datadir="$datadir" --pid-file="$mysqld_pid_file_path" $other_args >/dev/null 2>&1 &
行,改為:
$bindir/mysqld_safe --defaults-file=/usr/local/mariadb/my.cnf --datadir="$datadir" --pid-file="$mysqld_pid_file_path" $other_args >/dev/null 2>&1 &
即新增了--defaults-file=/usr/local/mariadb/my.cnf
:wq
# chmod +x /etc/init.d/mariadb
# chkconfig mariadb on
配置/usr/local/mariadb/my.cnf
在[mysqld]模組新增下面的幾行:
log-error = /usr/local/mariadb/logs/mariadb_error.log
pid-file = /usr/local/mariadb/mariadb.pid
user=mariadb
datadir = /data/mariadb
basedir = /usr/local/mariadb
新增加mysqld_safe塊
[mysqld_safe]
log-error = /usr/local/mariadb/logs/mariadb_error.log
pid-file = /usr/local/mariadb/mariadb.pid
啟動前修下目錄許可權
# chown -R mariadb:mariadb /data/mariadb
# chown -R mariadb:mariadb /data/mariadb/.
# chown -R mariadb:mariadb /usr/local/mariadb
# chown -R mariadb:mariadb /usr/local/mariadb/.
啟動MariaDB:
# /etc/init.d/mariadb start
注:如果啟動失敗,檢視下/usr/local/mariadb/logs/mariadb_error.log檔案看報什麼錯,修正即可。
設定root的密碼
# /usr/local/mariadb/bin/mysqladmin -u root password '123456'
進入MariaDB的shell下
[root@localhost mariadb]# /usr/local/mariadb/bin/mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 4
Server version: 10.0.24-MariaDB Source distribution
Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> show engines\G;
*************************** 1. row ***************************
Engine: InnoDB
Support: DEFAULT
Comment: Percona-XtraDB, Supports transactions, row-level locking, and foreign keys
Transactions: YES
XA: YES
Savepoints: YES
*************************** 2. row ***************************
Engine: MRG_MyISAM
Support: YES
Comment: Collection of identical MyISAM tables
Transactions: NO
XA: NO
Savepoints: NO
*************************** 3. row ***************************
Engine: CSV
Support: YES
Comment: CSV storage engine
Transactions: NO
XA: NO
Savepoints: NO
*************************** 4. row ***************************
Engine: BLACKHOLE
Support: YES
Comment: /dev/null storage engine (anything you write to it disappears)
Transactions: NO
XA: NO
Savepoints: NO
*************************** 5. row ***************************
Engine: MyISAM
Support: YES
Comment: MyISAM storage engine
Transactions: NO
XA: NO
Savepoints: NO
*************************** 6. row ***************************
Engine: MEMORY
Support: YES
Comment: Hash based, stored in memory, useful for temporary tables
Transactions: NO
XA: NO
Savepoints: NO
*************************** 7. row ***************************
Engine: ARCHIVE
Support: YES
Comment: Archive storage engine
Transactions: NO
XA: NO
Savepoints: NO
*************************** 8. row ***************************
Engine: PERFORMANCE_SCHEMA
Support: YES
Comment: Performance Schema
Transactions: NO
XA: NO
Savepoints: NO
*************************** 9. row ***************************
Engine: FEDERATED
Support: YES
Comment: FederatedX pluggable storage engine
Transactions: YES
XA: NO
Savepoints: YES
*************************** 10. row ***************************
Engine: Aria
Support: YES
Comment: Crash-safe tables with MyISAM heritage
Transactions: NO
XA: NO
Savepoints: NO
10 rows in set (0.00 sec)
ERROR: No query specified
MariaDB [mysql]> use mysql; //選擇系統資料庫mysql
MariaDB [mysql]> select Host,User,Password from user; //檢視所有使用者
MariaDB [mysql]> delete from user where password="";
MariaDB [mysql]> GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY '123456'; //為root新增遠端連線許可權
MariaDB [mysql]> flush privileges;
MariaDB [mysql]> select Host,User,Password from user; //確認密碼為空的使用者是否已全部刪除
MariaDB [mysql]> exit;
設定防火牆,以便區域網內的其它伺服器可以訪問
# vim /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3309 -j ACCEPT
# /etc/init.d/iptables save
# /etc/init.d/iptables restart
MariaDB埠:3309 (因為本機原先已經裝的有MySQL了,不想刪除MySQL)
#wget
# wget -O
建立mariadb使用者
# groupadd -r mariadb
# useradd -g mariadb -r -M -s /sbin/nologin mariadb //禁止mariadb使用者本地登入
依賴元件
# yum -y install gcc gcc-c++ make cmake ncurses ncurses-devel libxml2 libxml2-devel openssl-devel bison bison-devel
# tar -zxvf mariadb-10.0.24.tar.gz
# cd mariadb-10.0.24
# cmake . -DMYSQL_UNIX_ADDR=/tmp/mariadb.sock -DSYSCONFDIR=/usr/local/mariadb -DMYSQL_TCP_PORT=3309 -DEXTRA_CHARSETS=all -DMYSQL_USER=mariadb -DCMAKE_INSTALL_PREFIX=/usr/local/mariadb -DMYSQL_DATADIR=/data/mariadb -DWITH_XTRADB_STORAGE_ENGINE=1 -DWITH_FEDERATEDX_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_MYISAM_STORAGE_ENGINE=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 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci
# make -j 4 && make install
把MariaDB服務加入系統環境變數:在最後新增下面這一行
# vim /etc/profile
export PATH=/usr/local/mariadb/bin:$PATH
# source /etc/profile
複製配置檔案
# cp /usr/local/mariadb/support-files/my-large.cnf /usr/local/mariadb/my.cnf
初始化資料庫
# /usr/local/mariadb/scripts/mysql_install_db --basedir=/usr/local/mariadb --datadir=/data/mariadb --user=mariadb --defaults-file=/usr/local/mariadb/my.cnf
複製服務啟動指令碼
# cp /usr/local/mariadb/support-files/mysql.server /etc/init.d/mariadb
# vim /etc/init.d/mariadb
找到
$bindir/mysqld_safe --datadir="$datadir" --pid-file="$mysqld_pid_file_path" $other_args >/dev/null 2>&1 &
行,改為:
$bindir/mysqld_safe --defaults-file=/usr/local/mariadb/my.cnf --datadir="$datadir" --pid-file="$mysqld_pid_file_path" $other_args >/dev/null 2>&1 &
即新增了--defaults-file=/usr/local/mariadb/my.cnf
:wq
# chmod +x /etc/init.d/mariadb
# chkconfig mariadb on
配置/usr/local/mariadb/my.cnf
在[mysqld]模組新增下面的幾行:
log-error = /usr/local/mariadb/logs/mariadb_error.log
pid-file = /usr/local/mariadb/mariadb.pid
user=mariadb
datadir = /data/mariadb
basedir = /usr/local/mariadb
新增加mysqld_safe塊
[mysqld_safe]
log-error = /usr/local/mariadb/logs/mariadb_error.log
pid-file = /usr/local/mariadb/mariadb.pid
啟動前修下目錄許可權
# chown -R mariadb:mariadb /data/mariadb
# chown -R mariadb:mariadb /data/mariadb/.
# chown -R mariadb:mariadb /usr/local/mariadb
# chown -R mariadb:mariadb /usr/local/mariadb/.
啟動MariaDB:
# /etc/init.d/mariadb start
注:如果啟動失敗,檢視下/usr/local/mariadb/logs/mariadb_error.log檔案看報什麼錯,修正即可。
設定root的密碼
# /usr/local/mariadb/bin/mysqladmin -u root password '123456'
進入MariaDB的shell下
[root@localhost mariadb]# /usr/local/mariadb/bin/mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 4
Server version: 10.0.24-MariaDB Source distribution
Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> show engines\G;
*************************** 1. row ***************************
Engine: InnoDB
Support: DEFAULT
Comment: Percona-XtraDB, Supports transactions, row-level locking, and foreign keys
Transactions: YES
XA: YES
Savepoints: YES
*************************** 2. row ***************************
Engine: MRG_MyISAM
Support: YES
Comment: Collection of identical MyISAM tables
Transactions: NO
XA: NO
Savepoints: NO
*************************** 3. row ***************************
Engine: CSV
Support: YES
Comment: CSV storage engine
Transactions: NO
XA: NO
Savepoints: NO
*************************** 4. row ***************************
Engine: BLACKHOLE
Support: YES
Comment: /dev/null storage engine (anything you write to it disappears)
Transactions: NO
XA: NO
Savepoints: NO
*************************** 5. row ***************************
Engine: MyISAM
Support: YES
Comment: MyISAM storage engine
Transactions: NO
XA: NO
Savepoints: NO
*************************** 6. row ***************************
Engine: MEMORY
Support: YES
Comment: Hash based, stored in memory, useful for temporary tables
Transactions: NO
XA: NO
Savepoints: NO
*************************** 7. row ***************************
Engine: ARCHIVE
Support: YES
Comment: Archive storage engine
Transactions: NO
XA: NO
Savepoints: NO
*************************** 8. row ***************************
Engine: PERFORMANCE_SCHEMA
Support: YES
Comment: Performance Schema
Transactions: NO
XA: NO
Savepoints: NO
*************************** 9. row ***************************
Engine: FEDERATED
Support: YES
Comment: FederatedX pluggable storage engine
Transactions: YES
XA: NO
Savepoints: YES
*************************** 10. row ***************************
Engine: Aria
Support: YES
Comment: Crash-safe tables with MyISAM heritage
Transactions: NO
XA: NO
Savepoints: NO
10 rows in set (0.00 sec)
ERROR: No query specified
MariaDB [mysql]> use mysql; //選擇系統資料庫mysql
MariaDB [mysql]> select Host,User,Password from user; //檢視所有使用者
MariaDB [mysql]> delete from user where password="";
MariaDB [mysql]> GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY '123456'; //為root新增遠端連線許可權
MariaDB [mysql]> flush privileges;
MariaDB [mysql]> select Host,User,Password from user; //確認密碼為空的使用者是否已全部刪除
MariaDB [mysql]> exit;
設定防火牆,以便區域網內的其它伺服器可以訪問
# vim /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3309 -j ACCEPT
# /etc/init.d/iptables save
# /etc/init.d/iptables restart
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9034054/viewspace-2074646/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- centos PHP 編譯安裝CentOSPHP編譯
- CentOS 下編譯安裝 NginxCentOS編譯Nginx
- CentOS 下編譯安裝 apacheCentOS編譯Apache
- CentOS 6.4 編譯安裝 apacheCentOS編譯Apache
- Centos 下編譯安裝RedisCentOS編譯Redis
- Centos7編譯安裝OpenRestyCentOS編譯REST
- Centos 編譯安裝 PHP7.4.7CentOS編譯PHP
- Centos8編譯安裝核心CentOS編譯
- 如何在CentOS7安裝Node?(編譯安裝)CentOS編譯
- CentOS 下編譯安裝 PHP7.2CentOS編譯PHP
- Centos7編譯安裝Apache教程。CentOS編譯Apache
- Centos7編譯安裝Memcached教程。CentOS編譯
- Centos7編譯安裝Docker教程。CentOS編譯Docker
- Linux Centos下編譯安裝RedisLinuxCentOS編譯Redis
- centos7下編譯安裝lnmpCentOS編譯LNMP
- CentOS 全新編譯安裝 Python3.8CentOS編譯Python
- httpd-2.4 編譯安裝(centos6)httpd編譯CentOS
- Centos7編譯安裝Tomcat教程。CentOS編譯Tomcat
- centos手動編譯安裝apache、php、mysqlCentOS編譯ApachePHPMySql
- CentOS6 編譯安裝 redis-3.2.3CentOS編譯Redis
- CentOS 6.4下編譯安裝MySQL 5.6.14CentOS編譯MySql
- CentOS 7 原始碼編譯安裝 Mysql 5.7CentOS原始碼編譯MySql
- 在Centos5.2下編譯安裝LAMPCentOS編譯LAMP
- centos7 編譯安裝imagemagick7.1CentOS編譯
- CentOS 下編譯安裝 PHP7.2(nginx 版)CentOS編譯PHPNginx
- CentOS 下編譯安裝 PHP7.2(apache 版)CentOS編譯PHPApache
- Centos7編譯安裝kafka-manager教程CentOS編譯Kafka
- CentOS7編譯和安裝GCC7.5CentOS編譯GC
- CentOS下編譯安裝Python3教程CentOS編譯Python
- Centos 7.6 下Mysql8.0.16編譯安裝CentOSMySql編譯
- Centos7下原始碼編譯安裝apacheCentOS原始碼編譯Apache
- centos7編譯安裝python3CentOS編譯Python
- Centos下Ambari2.7.5的編譯和安裝CentOS編譯
- CentOS 7下編譯安裝Python3CentOS編譯Python
- Centos7編譯安裝Pure-Ftpd教程。CentOS編譯FTP
- centos 5.8 編譯安裝 percona server 5.6.33CentOS編譯Server
- Centos下Sphinx的下載與編譯安裝CentOS編譯
- CentOS7.3編譯安裝Nginx1.10.1CentOS編譯Nginx