二進制安裝數據庫MariaDB

      網友投稿 1035 2022-05-29

      =================================

      /*

      * @系統:CentOS7.9

      *?@描述:數據庫安裝的幾種方法二

      */

      二進制安裝數據庫MariaDB

      =================================

      一、獲取安裝包

      二進制包

      #進入到安裝包存放位置 # cd /usr/local/src/ #上傳文件 # rz #選擇上傳文件 # ls mariadb-10.5.4-linux-x86_64.tar.gz

      二、安裝

      1. 檢查環境

      # ss -ntl #檢查端口 State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 128 *:22 *:* LISTEN 0 100 127.0.0.1:25 *:* LISTEN 0 128 [::]:22 [::]:* LISTEN 0 100 [::1]:25 [::]:* # rpm -q mysql package mysql is not installed # rpm -q mariadb package mariadb is not installed # getent passwd mysql #檢查mysql用戶是否創建

      2. 創建用戶和組

      # useradd -r -d /data/mariadb -s /sbin/nologin mysql # getent passwd mysql mysql:x:998:996::/data/mariadb:/sbin/nologin # id mysql uid=998(mysql) gid=996(mysql) groups=996(mysql)

      3. 解壓到指定路徑并創建軟連接

      # tar xvf mariadb-10.5.4-linux-x86_64.tar.gz -C /usr/local/ # cd /usr/local/ # ls bin etc games include lib lib64 libexec mariadb-10.5.4-linux-x86_64 sbin share src # ln -s mariadb-10.5.4-linux-x86_64/ mysql

      4. 修改所所有者

      # ls -l mysql/ total 176 drwxrwxr-x 2 1000 1000 4096 Jun 22 11:50 bin -rw-r--r-- 1 1000 1000 17987 Jun 23 23:10 COPYING -rw-r--r-- 1 1000 1000 2354 Jun 23 23:10 CREDITS -rw-r--r-- 1 1000 1000 8245 Jun 23 23:10 EXCEPTIONS-CLIENT drwxrwxr-x 3 1000 1000 19 Jun 23 23:39 include -rw-r--r-- 1 1000 1000 8782 Jun 23 23:10 INSTALL-BINARY drwxrwxr-x 5 1000 1000 275 Jun 22 11:50 lib drwxrwxr-x 4 1000 1000 30 Jun 23 23:39 man drwxrwxr-x 9 1000 1000 4096 Jun 23 23:39 mysql-test -rw-r--r-- 1 1000 1000 2973 Jun 23 23:10 README.md -rw-r--r-- 1 1000 1000 19520 Jun 23 23:10 README-wsrep drwxrwxr-x 2 1000 1000 56 Jun 23 23:39 scripts drwxrwxr-x 31 1000 1000 4096 Jun 23 23:39 share drwxrwxr-x 4 1000 1000 4096 Jun 23 23:39 sql-bench drwxrwxr-x 3 1000 1000 165 Jun 23 23:39 support-files -rw-r--r-- 1 1000 1000 86263 Jun 23 23:10 THIRDPARTY # chown -R root:root mysql/ # ls -l mysql/ total 176 drwxrwxr-x 2 root root 4096 Jun 22 11:50 bin -rw-r--r-- 1 root root 17987 Jun 23 23:10 COPYING -rw-r--r-- 1 root root 2354 Jun 23 23:10 CREDITS -rw-r--r-- 1 root root 8245 Jun 23 23:10 EXCEPTIONS-CLIENT drwxrwxr-x 3 root root 19 Jun 23 23:39 include -rw-r--r-- 1 root root 8782 Jun 23 23:10 INSTALL-BINARY drwxrwxr-x 5 root root 275 Jun 22 11:50 lib drwxrwxr-x 4 root root 30 Jun 23 23:39 man drwxrwxr-x 9 root root 4096 Jun 23 23:39 mysql-test -rw-r--r-- 1 root root 2973 Jun 23 23:10 README.md -rw-r--r-- 1 root root 19520 Jun 23 23:10 README-wsrep drwxrwxr-x 2 root root 56 Jun 23 23:39 scripts drwxrwxr-x 31 root root 4096 Jun 23 23:39 share drwxrwxr-x 4 root root 4096 Jun 23 23:39 sql-bench drwxrwxr-x 3 root root 165 Jun 23 23:39 support-files -rw-r--r-- 1 root root 86263 Jun 23 23:10 THIRDPARTY

      5. 添加環境變量

      # echo PATH=/usr/local/mysql/bin:$PATH > /etc/profile.d/mysql.sh # . /etc/profile.d/mysql.sh # echo $PATH /usr/local/mysql/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin

      三、配置

      1. 修改數據庫存放位置(可以新增一個磁盤存放)

      # mkdir /data/mariadb

      2. 修改屬組

      # chown -R mysql.mysql /data/mariadb

      3. 修改權限(為了安全需要修改權限為770)

      # chmod 770 /data/mariadb

      四、初始化

      1. 進入到二進制程序目錄

      # cd /usr/local/mysql/

      2. 執行初始化腳本文件(切記不要進入到進腳本存放位置的文件夾)

      # scripts/mariadb-install-db --datadir=/data/mariadb --user=mysql Installing MariaDB/MySQL system tables in '/data/mariadb' ...OK #出現這個就證明沒問題了(有些可能只有mysql_install_db,一樣一樣的)

      3. 修改配置文件(因為沒有找到提供的配置文件,所以直接使用原有的)

      # cd # vim /etc/my.cnf ================================ [mysqld] datadir=/data/mariadb socket=/usr/local/mysql/mysql.sock [client] port=3306 socket=/usr/local/mysql/mysql.sock

      4. 設置開機自啟動

      # cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mariadb #拷貝啟動腳本 # chkconfig --list #查詢啟動服務列表 Note: This output shows SysV services only and does not include native systemd services. SysV configuration data might be overridden by native systemd configuration. If you want to list systemd services use 'systemctl list-unit-files'. To see services enabled on particular target use 'systemctl list-dependencies [target]'. netconsole 0:off 1:off 2:off 3:off 4:off 5:off 6:off network 0:off 1:off 2:on 3:on 4:on 5:on 6:off # chkconfig --add mariadb #添加啟動服務 # chkconfig --list Note: This output shows SysV services only and does not include native systemd services. SysV configuration data might be overridden by native systemd configuration. If you want to list systemd services use 'systemctl list-unit-files'. To see services enabled on particular target use 'systemctl list-dependencies [target]'. mariadb 0:off 1:off 2:on 3:on 4:on 5:on 6:off netconsole 0:off 1:off 2:off 3:off 4:off 5:off 6:off network 0:off 1:off 2:on 3:on 4:on 5:on 6:off

      5. 設置權限

      # setfacl -R -m u:mysql:rwx /usr/local/mysql/ #授予mysql用戶讀寫執行權限 #注:也可以將socket文件放到有執行權限的文件夾中

      6. 添加服務

      # systemctl start mariadb # ss -nutl Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port tcp LISTEN 0 128 *:22 *:* tcp LISTEN 0 100 127.0.0.1:25 *:* tcp LISTEN 0 128 [::]:22 [::]:* tcp LISTEN 0 100 [::1]:25 [::]:* tcp LISTEN 0 80 [::]:3306 [::]:*

      7. 運行安全腳本

      # mysql_secure_installation #執行后出現報錯,需要修改socket路徑 # /usr/local/mysql/bin/mysqld --print-defaults #查看編譯路徑 /usr/local/mysql/bin/mysqld would have been started with the following arguments: --datadir=/data/mariadb --socket=/tmp/mysql.sock --symbolic-links=0 #解決方案 # vim /etc/my.cnf ================ [mysqld] datadir=/data/mariadb socket=/tmp/mysql.sock # socket=/usr/local/mysql/mysql.sock [client] port=3306 socket=/tmp/mysql.sock # socket=/usr/local/mysql/mysql.sock [root@51try ~]# systemctl restart mariadb #重啟服務 [root@51try ~]# mysql_secure_installation ======================================= Enter current password for root (enter for none): OK, successfully used password, moving on... Setting the root password or using the unix_socket ensures that nobody can log into the MariaDB root user without the proper authorisation. You already have your root account protected, so you can safely answer 'n'. Switch to unix_socket authentication [Y/n] y Enabled successfully! Reloading privilege tables.. ... Success! You already have your root account protected, so you can safely answer 'n'. Change the root password? [Y/n] y #設置密碼 New password: root1234 Re-enter new password: root1234 Password updated successfully! Reloading privilege tables.. ... Success! 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. Disallow root login remotely? [Y/n] n #是否禁用root用戶遠程登錄 ... skipping. 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. 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. 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!

      8. 設置開機啟動

      # /sbin/chkconfig mariadb on

      五、連接數據庫

      # mysql -uroot -p #切記不要在-p后面加密碼,這樣等于明文 Enter password: MariaDB [(none)]> status --查看一下信息 -------------- mysql Ver 15.1 Distrib 10.5.4-MariaDB, for Linux (x86_64) using readline 5.1 MariaDB [(none)]> \q --退出數據庫 Bye

      未完待續......

      --本篇完--

      Linux 彈性云服務器 ECS 數據庫

      版權聲明:本文內容由網絡用戶投稿,版權歸原作者所有,本站不擁有其著作權,亦不承擔相應法律責任。如果您發現本站中有涉嫌抄襲或描述失實的內容,請聯系我們jiasou666@gmail.com 處理,核實后本網站將在24小時內刪除侵權內容。

      上一篇:跨平臺數據備份工具之restic
      下一篇:昇騰訓練營應用營第一課筆記
      相關文章
      久久精品国产亚洲7777| 久久精品国产亚洲77777| 亚洲国产日产无码精品| 亚洲国产综合专区电影在线 | 国产亚洲色视频在线| 亚洲av无一区二区三区| 亚洲熟妇av午夜无码不卡| 激情亚洲一区国产精品| 亚洲一区二区无码偷拍| 亚洲精品视频专区| 亚洲日韩中文字幕天堂不卡| 亚洲网站视频在线观看| 亚洲大香伊人蕉在人依线| 亚洲成综合人影院在院播放| 亚洲春黄在线观看| 亚洲不卡在线观看| 最新国产精品亚洲| 亚洲精品成a人在线观看☆| 大桥未久亚洲无av码在线| 亚洲va中文字幕无码| 亚洲七七久久精品中文国产| 久久久无码精品亚洲日韩软件| 日韩精品一区二区亚洲AV观看| 国产精品亚洲二区在线观看| 国产亚洲精品自在线观看| 中文字幕亚洲一区| 亚洲va无码va在线va天堂| 亚洲福利在线观看| 亚洲无限乱码一二三四区| 亚洲av无码片区一区二区三区| 丁香婷婷亚洲六月综合色| 亚洲日本VA午夜在线影院| 亚洲精品无播放器在线播放 | 最新亚洲精品国偷自产在线| 亚洲风情亚Aⅴ在线发布| 亚洲成a人片在线观看日本麻豆| 久久久青草青青国产亚洲免观| 国产精品亚洲成在人线| 亚洲一区二区三区夜色| 亚洲日韩中文字幕| 亚洲av永久无码一区二区三区|