【linux】debian10安裝mariadb數據庫(mysql替代品)

1.安裝mariadb數據庫

apt-get install mariadb-server

運行示例

root@vps:~# apt-get install mariadb-server
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  galera-3 gawk libaio1 libcgi-fast-perl libcgi-pm-perl
  libconfig-inifiles-perl libdbd-mysql-perl libdbi-perl libencode-locale-perl
  libfcgi-perl libhtml-parser-perl libhtml-tagset-perl libhtml-template-perl
  libhttp-date-perl libhttp-message-perl libio-html-perl
  liblwp-mediatypes-perl libmpfr6 libreadline5 libsigsegv2 libsnappy1v5
  libterm-readkey-perl libtimedate-perl liburi-perl mariadb-client-10.3
  mariadb-client-core-10.3 mariadb-server-10.3 mariadb-server-core-10.3 rsync
  socat
Suggested packages:
  gawk-doc libclone-perl libmldbm-perl libnet-daemon-perl
  libsql-statement-perl libdata-dump-perl libipc-sharedcache-perl libwww-perl
  mariadb-test netcat-openbsd tinyca
The following NEW packages will be installed:
  galera-3 gawk libaio1 libcgi-fast-perl libcgi-pm-perl
  libconfig-inifiles-perl libdbd-mysql-perl libdbi-perl libencode-locale-perl
  libfcgi-perl libhtml-parser-perl libhtml-tagset-perl libhtml-template-perl
  libhttp-date-perl libhttp-message-perl libio-html-perl
  liblwp-mediatypes-perl libmpfr6 libreadline5 libsigsegv2 libsnappy1v5
  libterm-readkey-perl libtimedate-perl liburi-perl mariadb-client-10.3
  mariadb-client-core-10.3 mariadb-server mariadb-server-10.3
  mariadb-server-core-10.3 rsync socat
0 upgraded, 31 newly installed, 0 to remove and 0 not upgraded.
Need to get 21.9 MB of archives.
After this operation, 169 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://deb.debian.org/debian buster/main amd64 libmpfr6 amd64 4.0.2-1 [775 kB]
Get:2 http://deb.debian.org/debian buster/main amd64 libsigsegv2 amd64 2.12-2 [32.8 kB]
Get:3 http://deb.debian.org/debian buster/main amd64 gawk amd64 1:4.2.1+dfsg-1 [660 kB]
Get:4 http://deb.debian.org/debian buster/main amd64 galera-3 amd64 25.3.25-2 [920 kB]
Get:5 http://deb.debian.org/debian buster/main amd64 libdbi-perl amd64 1.642-1+b1 [775 kB]
Get:6 http://deb.debian.org/debian buster/main amd64 libconfig-inifiles-perl all 3.000001-1 [51.9 kB]
Get:7 http://deb.debian.org/debian buster/main amd64 libaio1 amd64 0.3.112-3 [11.2 kB]
Get:8 http://deb.debian.org/debian buster/main amd64 libreadline5 amd64 5.2+dfsg-3+b13 [120 kB]
Get:9 http://deb.debian.org/debian buster/main amd64 libsnappy1v5 amd64 1.1.7-1 [17.0 kB]
Get:10 http://deb.debian.org/debian buster/main amd64 mariadb-client-core-10.3 amd64 1:10.3.18-0+deb10u1 [5662 kB]
Get:11 http://deb.debian.org/debian buster/main amd64 mariadb-client-10.3 amd64 1:10.3.18-0+deb10u1 [1139 kB]
Get:12 http://deb.debian.org/debian buster/main amd64 mariadb-server-core-10.3 amd64 1:10.3.18-0+deb10u1 [5921 kB]
Get:13 http://deb.debian.org/debian buster/main amd64 rsync amd64 3.1.3-6 [397 kB]
Get:14 http://deb.debian.org/debian buster/main amd64 socat amd64 1.7.3.2-2 [358 kB]
Get:15 http://deb.debian.org/debian buster/main amd64 mariadb-server-10.3 amd64 1:10.3.18-0+deb10u1 [4201 kB]
Get:16 http://deb.debian.org/debian buster/main amd64 libhtml-tagset-perl all 3.20-3 [12.7 kB]
Get:17 http://deb.debian.org/debian buster/main amd64 liburi-perl all 1.76-1 [89.9 kB]
Get:18 http://deb.debian.org/debian buster/main amd64 libhtml-parser-perl amd64 3.72-3+b3 [105 kB]
Get:19 http://deb.debian.org/debian buster/main amd64 libcgi-pm-perl all 4.40-1 [222 kB]
Get:20 http://deb.debian.org/debian buster/main amd64 libfcgi-perl amd64 0.78-2+b3 [39.0 kB]
Get:21 http://deb.debian.org/debian buster/main amd64 libcgi-fast-perl all 1:2.13-1 [11.4 kB]
Get:22 http://deb.debian.org/debian buster/main amd64 libdbd-mysql-perl amd64 4.050-2 [121 kB]
Get:23 http://deb.debian.org/debian buster/main amd64 libencode-locale-perl all 1.05-1 [13.7 kB]
Get:24 http://deb.debian.org/debian buster/main amd64 libhtml-template-perl all 2.97-1 [66.0 kB]
Get:25 http://deb.debian.org/debian buster/main amd64 libtimedate-perl all 2.3000-2 [42.2 kB]
Get:26 http://deb.debian.org/debian buster/main amd64 libhttp-date-perl all 6.02-1 [10.7 kB]
Get:27 http://deb.debian.org/debian buster/main amd64 libio-html-perl all 1.001-1 [17.6 kB]
Get:28 http://deb.debian.org/debian buster/main amd64 liblwp-mediatypes-perl all 6.02-1 [22.1 kB]
Get:29 http://deb.debian.org/debian buster/main amd64 libhttp-message-perl all 6.18-1 [77.8 kB]
Get:30 http://deb.debian.org/debian buster/main amd64 libterm-readkey-perl amd64 2.38-1 [27.4 kB]
Get:31 http://deb.debian.org/debian buster/main amd64 mariadb-server all 1:10.3.18-0+deb10u1 [30.7 kB]
Fetched 21.9 MB in 0s (52.9 MB/s)     
Extracting templates from packages: 100%
Preconfiguring packages ...
Selecting previously unselected package libmpfr6:amd64.
(Reading database ... 32208 files and directories currently installed.)
Preparing to unpack .../libmpfr6_4.0.2-1_amd64.deb ...
Unpacking libmpfr6:amd64 (4.0.2-1) ...
Selecting previously unselected package libsigsegv2:amd64.
Preparing to unpack .../libsigsegv2_2.12-2_amd64.deb ...
Unpacking libsigsegv2:amd64 (2.12-2) ...
Setting up libmpfr6:amd64 (4.0.2-1) ...
Setting up libsigsegv2:amd64 (2.12-2) ...
Selecting previously unselected package gawk.
(Reading database ... 32228 files and directories currently installed.)
Preparing to unpack .../00-gawk_1%3a4.2.1+dfsg-1_amd64.deb ...
Unpacking gawk (1:4.2.1+dfsg-1) ...
Selecting previously unselected package galera-3.
Preparing to unpack .../01-galera-3_25.3.25-2_amd64.deb ...
Unpacking galera-3 (25.3.25-2) ...
Selecting previously unselected package libdbi-perl:amd64.
Preparing to unpack .../02-libdbi-perl_1.642-1+b1_amd64.deb ...
Unpacking libdbi-perl:amd64 (1.642-1+b1) ...
Selecting previously unselected package libconfig-inifiles-perl.
Preparing to unpack .../03-libconfig-inifiles-perl_3.000001-1_all.deb ...
Unpacking libconfig-inifiles-perl (3.000001-1) ...
Selecting previously unselected package libaio1:amd64.
Preparing to unpack .../04-libaio1_0.3.112-3_amd64.deb ...
Unpacking libaio1:amd64 (0.3.112-3) ...
Selecting previously unselected package libreadline5:amd64.
Preparing to unpack .../05-libreadline5_5.2+dfsg-3+b13_amd64.deb ...
Unpacking libreadline5:amd64 (5.2+dfsg-3+b13) ...
Selecting previously unselected package libsnappy1v5:amd64.
Preparing to unpack .../06-libsnappy1v5_1.1.7-1_amd64.deb ...
Unpacking libsnappy1v5:amd64 (1.1.7-1) ...
Selecting previously unselected package mariadb-client-core-10.3.
Preparing to unpack .../07-mariadb-client-core-10.3_1%3a10.3.18-0+deb10u1_amd64.deb ...
Unpacking mariadb-client-core-10.3 (1:10.3.18-0+deb10u1) ...
Selecting previously unselected package mariadb-client-10.3.
Preparing to unpack .../08-mariadb-client-10.3_1%3a10.3.18-0+deb10u1_amd64.deb ...
Unpacking mariadb-client-10.3 (1:10.3.18-0+deb10u1) ...
Selecting previously unselected package mariadb-server-core-10.3.
Preparing to unpack .../09-mariadb-server-core-10.3_1%3a10.3.18-0+deb10u1_amd64.deb ...
Unpacking mariadb-server-core-10.3 (1:10.3.18-0+deb10u1) ...
Selecting previously unselected package rsync.
Preparing to unpack .../10-rsync_3.1.3-6_amd64.deb ...
Unpacking rsync (3.1.3-6) ...
Selecting previously unselected package socat.
Preparing to unpack .../11-socat_1.7.3.2-2_amd64.deb ...
Unpacking socat (1.7.3.2-2) ...
Selecting previously unselected package mariadb-server-10.3.
Preparing to unpack .../12-mariadb-server-10.3_1%3a10.3.18-0+deb10u1_amd64.deb ...
Unpacking mariadb-server-10.3 (1:10.3.18-0+deb10u1) ...
Selecting previously unselected package libhtml-tagset-perl.
Preparing to unpack .../13-libhtml-tagset-perl_3.20-3_all.deb ...
Unpacking libhtml-tagset-perl (3.20-3) ...
Selecting previously unselected package liburi-perl.
Preparing to unpack .../14-liburi-perl_1.76-1_all.deb ...
Unpacking liburi-perl (1.76-1) ...
Selecting previously unselected package libhtml-parser-perl.
Preparing to unpack .../15-libhtml-parser-perl_3.72-3+b3_amd64.deb ...
Unpacking libhtml-parser-perl (3.72-3+b3) ...
Selecting previously unselected package libcgi-pm-perl.
Preparing to unpack .../16-libcgi-pm-perl_4.40-1_all.deb ...
Unpacking libcgi-pm-perl (4.40-1) ...
Selecting previously unselected package libfcgi-perl.
Preparing to unpack .../17-libfcgi-perl_0.78-2+b3_amd64.deb ...
Unpacking libfcgi-perl (0.78-2+b3) ...
Selecting previously unselected package libcgi-fast-perl.
Preparing to unpack .../18-libcgi-fast-perl_1%3a2.13-1_all.deb ...
Unpacking libcgi-fast-perl (1:2.13-1) ...
Selecting previously unselected package libdbd-mysql-perl:amd64.
Preparing to unpack .../19-libdbd-mysql-perl_4.050-2_amd64.deb ...
Unpacking libdbd-mysql-perl:amd64 (4.050-2) ...
Selecting previously unselected package libencode-locale-perl.
Preparing to unpack .../20-libencode-locale-perl_1.05-1_all.deb ...
Unpacking libencode-locale-perl (1.05-1) ...
Selecting previously unselected package libhtml-template-perl.
Preparing to unpack .../21-libhtml-template-perl_2.97-1_all.deb ...
Unpacking libhtml-template-perl (2.97-1) ...
Selecting previously unselected package libtimedate-perl.
Preparing to unpack .../22-libtimedate-perl_2.3000-2_all.deb ...
Unpacking libtimedate-perl (2.3000-2) ...
Selecting previously unselected package libhttp-date-perl.
Preparing to unpack .../23-libhttp-date-perl_6.02-1_all.deb ...
Unpacking libhttp-date-perl (6.02-1) ...
Selecting previously unselected package libio-html-perl.
Preparing to unpack .../24-libio-html-perl_1.001-1_all.deb ...
Unpacking libio-html-perl (1.001-1) ...
Selecting previously unselected package liblwp-mediatypes-perl.
Preparing to unpack .../25-liblwp-mediatypes-perl_6.02-1_all.deb ...
Unpacking liblwp-mediatypes-perl (6.02-1) ...
Selecting previously unselected package libhttp-message-perl.
Preparing to unpack .../26-libhttp-message-perl_6.18-1_all.deb ...
Unpacking libhttp-message-perl (6.18-1) ...
Selecting previously unselected package libterm-readkey-perl.
Preparing to unpack .../27-libterm-readkey-perl_2.38-1_amd64.deb ...
Unpacking libterm-readkey-perl (2.38-1) ...
Selecting previously unselected package mariadb-server.
Preparing to unpack .../28-mariadb-server_1%3a10.3.18-0+deb10u1_all.deb ...
Unpacking mariadb-server (1:10.3.18-0+deb10u1) ...
Setting up libconfig-inifiles-perl (3.000001-1) ...
Setting up libreadline5:amd64 (5.2+dfsg-3+b13) ...
Setting up gawk (1:4.2.1+dfsg-1) ...
Setting up libhtml-tagset-perl (3.20-3) ...
Setting up liblwp-mediatypes-perl (6.02-1) ...
Setting up libencode-locale-perl (1.05-1) ...
Setting up libsnappy1v5:amd64 (1.1.7-1) ...
Setting up socat (1.7.3.2-2) ...
Setting up libio-html-perl (1.001-1) ...
Setting up galera-3 (25.3.25-2) ...
Setting up libtimedate-perl (2.3000-2) ...
Setting up libfcgi-perl (0.78-2+b3) ...
Setting up libterm-readkey-perl (2.38-1) ...
Setting up libaio1:amd64 (0.3.112-3) ...
Setting up liburi-perl (1.76-1) ...
Setting up libdbi-perl:amd64 (1.642-1+b1) ...
Setting up rsync (3.1.3-6) ...
Created symlink /etc/systemd/system/multi-user.target.wants/rsync.service → /lib/systemd/system/rsync.service.
Setting up libhttp-date-perl (6.02-1) ...
Setting up mariadb-server-core-10.3 (1:10.3.18-0+deb10u1) ...
Setting up libdbd-mysql-perl:amd64 (4.050-2) ...
Setting up mariadb-client-core-10.3 (1:10.3.18-0+deb10u1) ...
Setting up libhtml-parser-perl (3.72-3+b3) ...
Setting up libhttp-message-perl (6.18-1) ...
Setting up libcgi-pm-perl (4.40-1) ...
Setting up libhtml-template-perl (2.97-1) ...
Setting up mariadb-client-10.3 (1:10.3.18-0+deb10u1) ...
Setting up mariadb-server-10.3 (1:10.3.18-0+deb10u1) ...
Created symlink /etc/systemd/system/mysql.service → /lib/systemd/system/mariadb.service.
Created symlink /etc/systemd/system/mysqld.service → /lib/systemd/system/mariadb.service.
Created symlink /etc/systemd/system/multi-user.target.wants/mariadb.service → /lib/systemd/system/mariadb.service.
Setting up libcgi-fast-perl (1:2.13-1) ...
Setting up mariadb-server (1:10.3.18-0+deb10u1) ...
Processing triggers for systemd (241-7~deb10u2) ...
Processing triggers for man-db (2.8.5-2) ...
Processing triggers for libc-bin (2.28-10) ...
root@vps:~# 

2.運行安全設置腳本

mysql_secure_installation

運行示例

root@vps:~# 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.

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.

You already have a root password set, so you can safely answer 'n'.

Change the 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.

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.

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!
root@vps:~# 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章