centos 7にmariaDBをインストールして全過程記録を初期化する
#mariaDBのインストールと初期化の全過程記録#
[terry@/home/terry]$sudo yum install mariadb-server
[terry@/home/terry]$sudo systemctl start mariadb
[terry@/home/terry]$sudo systemctl status mariadb
自己起動[terry@/home/terry]$sudo systemctl enable mariadbの設定
安全初期化(mysql_secure_installation)[terry@/home/terry]$sudo mysql_secure_Installationの下には安全初期化の作業があります
デフォルトの匿名アカウントの削除
リモート接続の禁止
デフォルトのtestデータベースの削除
先ほどの構成を再ロード
これでインストールが完了しました
バージョン番号[terry@/home/terry]$mysqladmin-u root-p version Enter password:mysqladmin Ver 9.0 Distrib 5.5.5.64-MariaDB,for Linux on x 86_64 Copyright © 2000, 2018, Oracle, MariaDB Corporation Ab and others.
[terry@/home/terry]$mysqladmin -u root -p version
[terry@/home/terry]$
[terry@/home/terry]$sudo yum install mariadb-server
[sudo] password for terry:
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
base: mirrors.aliyun.com
extras: mirrors.aliyun.com
updates: mirrors.aliyun.com
base | 3.6 kB 00:00:00
extras | 2.9 kB 00:00:00
mongodb-org-3.2 | 2.5 kB 00:00:00
updates | 2.9 kB 00:00:00
Resolving Dependencies
--> Running transaction check
---> Package mariadb-server.x86_64 1:5.5.64-1.el7 will be installed
--> Processing Dependency: mariadb-libs(x86-64) = 1:5.5.64-1.el7 for package: 1:mariadb-server-5.5.64-1.el7.x86_64
--> Processing Dependency: mariadb(x86-64) = 1:5.5.64-1.el7 for package: 1:mariadb-server-5.5.64-1.el7.x86_64
--> Processing Dependency: perl-DBD-MySQL for package: 1:mariadb-server-5.5.64-1.el7.x86_64
--> Running transaction check
---> Package mariadb.x86_64 1:5.5.64-1.el7 will be installed
---> Package mariadb-libs.x86_64 1:5.5.64-1.el7 will be installed
---> Package perl-DBD-MySQL.x86_64 0:4.023-6.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
Installing:
Installing for dependencies:
| packageName | Type | version | base | 11 M |
| ----- | ------ | -------------- | -----|----- |
| mariadb | x86_64 | 1:5.5.64-1.el7 | base | 8.7 M |
| mariadb-libs | x86_64 | 1:5.5.64-1.el7 | base | 759 k |
| perl-DBD-MySQL | x86_64 | 4.023-6.el7 | base | 140 k |
Transaction Summary
============================
Install 1 Package (+3 Dependent packages)
Total download size: 21 M
Installed size: 112 M
Is this ok [y/d/N]: y
Downloading packages:
(1/4): mariadb-libs-5.5.64-1.el7.x86_64.rpm | 759 kB 00:00:00
(2/4): mariadb-5.5.64-1.el7.x86_64.rpm | 8.7 MB 00:00:01
(3/4): perl-DBD-MySQL-4.023-6.el7.x86_64.rpm | 140 kB 00:00:00
(4/4): mariadb-server-5.5.64-1.el7.x86_64.rpm | 11 MB 00:00:01
Total 15 MB/s | 21 MB 00:00:01
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
** Found 2 pre-existing rpmdb problem(s), 'yum check' output follows:
2:postfix-2.10.1-7.el7.x86_64 has missing requires of libmysqlclient.so.18()(64bit)
2:postfix-2.10.1-7.el7.x86_64 has missing requires of libmysqlclient.so.18(libmysqlclient_18)(64bit)
Installing : 1:mariadb-libs-5.5.64-1.el7.x86_64 1/4
Installing : 1:mariadb-5.5.64-1.el7.x86_64 2/4
Installing : perl-DBD-MySQL-4.023-6.el7.x86_64 3/4
Installing : 1:mariadb-server-5.5.64-1.el7.x86_64 4/4
Verifying : 1:mariadb-libs-5.5.64-1.el7.x86_64 1/4
Verifying : 1:mariadb-5.5.64-1.el7.x86_64 2/4
Verifying : perl-DBD-MySQL-4.023-6.el7.x86_64 3/4
Verifying : 1:mariadb-server-5.5.64-1.el7.x86_64 4/4
Installed:
mariadb-server.x86_64 1:5.5.64-1.el7
Dependency Installed:
mariadb.x86_64 1:5.5.64-1.el7 mariadb-libs.x86_64 1:5.5.64-1.el7 perl-DBD-MySQL.x86_64 0:4.023-6.el7
Complete!
[terry@/home/terry]$sudo systemctl start mariadb
[terry@/home/terry]$sudo systemctl status mariadb
mariadb.service - MariaDB database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled)
Drop-In: /etc/systemd/system/mariadb.service.d
└─migrated-from-my.cnf-settings.conf
**Active: active (running)** since Tue 2020-02-11 16:09:31 CST; 9s ago
Process: 2020 ExecStartPost=/usr/libexec/mariadb-wait-ready $MAINPID (code=exited, status=0/SUCCESS)
Process: 1926 ExecStartPre=/usr/libexec/mariadb-prepare-db-dir %n (code=exited, status=0/SUCCESS)
Main PID: 2019 (mysqld_safe)
CGroup: /system.slice/mariadb.service
├─2019 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
└─2183 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/mariadb/mariadb.log --pid-file=/var/run/mariadb/maria...
Feb 11 16:09:29 VM_0_13_centos mariadb-prepare-db-dir[1926]: MySQL manual for more instructions.
Feb 11 16:09:29 VM_0_13_centos mariadb-prepare-db-dir[1926]: Please report any problems at http://mariadb.org/jira
Feb 11 16:09:29 VM_0_13_centos mariadb-prepare-db-dir[1926]: The latest information about MariaDB is available at http://mariadb.org/.
Feb 11 16:09:29 VM_0_13_centos mariadb-prepare-db-dir[1926]: You can find additional information about the MySQL part at:
Feb 11 16:09:29 VM_0_13_centos mariadb-prepare-db-dir[1926]: http://dev.mysql.com
Feb 11 16:09:29 VM_0_13_centos mariadb-prepare-db-dir[1926]: Consider joining MariaDB's strong and vibrant community:
Feb 11 16:09:29 VM_0_13_centos mariadb-prepare-db-dir[1926]: https://mariadb.org/get-involved/
Feb 11 16:09:29 VM_0_13_centos mysqld_safe[2019]: 200211 16:09:29 mysqld_safe Logging to '/var/log/mariadb/mariadb.log'.
Feb 11 16:09:29 VM_0_13_centos mysqld_safe[2019]: 200211 16:09:29 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
**Feb 11 16:09:31 VM_0_13_centos systemd[1]: Started MariaDB database server.**
自己起動[terry@/home/terry]$sudo systemctl enable mariadbの設定
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
安全初期化(mysql_secure_installation)[terry@/home/terry]$sudo 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.
** mysql root , , , 。**
Enter current password for root (enter for none):
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
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.
Set 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] n [ n, Y]
... Success!
デフォルトのtestデータベースの削除
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] n
... skipping.
先ほどの構成を再ロード
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!
これでインストールが完了しました
バージョン番号[terry@/home/terry]$mysqladmin-u root-p version Enter password:mysqladmin Ver 9.0 Distrib 5.5.5.64-MariaDB,for Linux on x 86_64 Copyright © 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Server version 5.5.64-MariaDB
Protocol version 10
Connection Localhost via UNIX socket
UNIX socket /var/lib/mysql/mysql.sock
Uptime: 6 min 27 sec
Threads: 1 Questions: 19 Slow queries: 0 Opens: 0 Flush tables: 2 Open tables: 26 Queries per second avg: 0.049
[terry@/home/terry]$mysqladmin -u root -p version
[terry@/home/terry]$