一、官網下載mariadb安裝包
Download MariaDB Server - MariaDB.org
找到對應的版本
下載安裝包后上傳到服務器這里不再贅述。
二、安裝二進制包
1、解壓安裝包
2、查看安裝包內的安裝提示文檔根據提示文檔進行安裝
# 解壓安裝包
tar xf mariadb-10.11.6-linux-systemd-x86_64
# 進入安裝包
d Testing."
mariadb-10.11.6-linux-systemd-x86_64]# ls
bin CREDITS include lib mysql-test README-wsrep share support-files
COPYING docs INSTALL-BINARY man README.md scripts sql-bench THIRDPARTY
mariadb-10.11.6-linux-systemd-x86_64]# head -n 10 INSTALL-BINARY
MariaDB and MySQL have identical install methods. In this document we
describe how to install MariaDB.The full documentation for installing MariaDB can be found at
https://mariadb.com/kb/en/library/binary-packages/
However most documentation at www.mysql.com also applies.2.2. Installing MariaDB from Generic Binaries on Unix/LinuxThis section covers the installation of MariaDB binary distributions
3、復制目錄到/usr/local下
4、創建MySQL用戶,給目錄授權MySQL權限
# 把安裝目錄復制到/usr/local下 這里可以任意目錄
cp -r mariadb-10.11.6-linux-systemd-x86_64 /usr/local/mysql
# 創建MySQL用戶 授予MySQL權限
useradd mysql
chown -R mysql:mysql /usr/local/mysql/# 創建日志目錄
mkdir -p /var/log/mariadb
cd /var/log/
chown mysql:mysql mariadb
5、初始化數據庫
mysql]# cd /usr/local/mysql/mysql]# scripts/mysql_install_db --user=mysql
Installing MariaDB/MySQL system tables in '/var/lib/mysql' ...
OKTo start mariadbd at boot time you have to copy
support-files/mariadb.service to the right place for your systemTwo all-privilege accounts were created.
One is root@localhost, it has no password, but you need to
be system 'root' user to connect. Use, for example, sudo mysql
The second is mysql@localhost, it has no password either, but
you need to be the system 'mysql' user to connect.
After connecting you can set the password, if you would need to be
able to connect as any of these users with a password and without sudoSee the MariaDB Knowledgebase at https://mariadb.com/kbYou can start the MariaDB daemon with:
cd '.' ; ./bin/mariadb-safe --datadir='/var/lib/mysql'You can test the MariaDB daemon with mysql-test-run.pl
cd './mysql-test' ; perl mariadb-test-run.plPlease report any problems at https://mariadb.org/jiraThe latest information about MariaDB is available at https://mariadb.org/.Consider joining MariaDB's strong and vibrant community:
https://mariadb.org/get-involved/
6、配置系統服務
# 啟動數據庫
bin/mysqld_safe --user=mysql &# 把啟動服務加到服務里
cd /usr/local/mysql/support-files
sudo cp mysql.server /etc/init.d/mariadb
sudo chmod +x /etc/init.d/mariadb
sudo systemctl enable mariadb
sudo systemctl start mariadb # 這里啟動會一直卡著直接ctrl退出就好了
致此安裝完成
三、驗證服務
配置賬號密碼及權限
bin]# cd /usr/local/mysql/bin
bin]# ./mariadb -uroot -p --socket=/var/lib/mysql/mysql.sock
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 10.11.6-MariaDB MariaDB ServerCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.MariaDB [(none)]> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123qweASD';
Query OK, 0 rows affected (0.002 sec)MariaDB [(none)]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.001 sec)
用另外一臺mysql登錄驗證賬號密碼及權限
# 輸入正確的密碼
mysql]# mysql -uroot -p -h 10.50.11.120
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 6
Server version: 10.11.6-MariaDB MariaDB ServerCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.MariaDB [(none)]> # 輸入錯誤的密碼
mysql]# mysql -uroot -p -h 10.50.11.120
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'10.50.78.121' (using password: YES)