Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

18.2 Initialize mariaDB services


May 24, 2021 That's what Linux should learn



Compared to MySQL, MariaDB database management systems have many new extension features, such as support for microsecond levels, thread pools, sub-query optimization, process reporting, and so on. Once the Yum software repository is configured, you are ready to install and deploy MariaDB database master and service-side programs.

After the installation is complete, remember to start the service program and add it to the boot item.

[root@linuxprobe ~]# yum install mariadb mariadb-server Loaded plugins: langpacks, product-id, subscription-manager .................. O mit some of the output information... I nstalling: mariadb x86_64 1:5.5.35-3.el7 rhel 8.9 M mariadb-server x86_64 1:5.5.35-3.el7 rhel 11 M Installing for dependencies: perl-Compress-Raw-Bzip2 x86_64 2.061-3.el7 rhel 32 k perl-Compress-Raw-Zlib x86_64 1:2.061-4.el7 rhel 57 k perl-DBD-MySQL x86_64 4.023-5.el7 rhel 140 k perl-DBI x86_64 1.627-4.el7 rhel 802 k perl-Data-Dumper x86_64 2.145-3.el7 rhel 47 k perl-IO-Compress noarch 2.061-2.el7 rhel 260 k perl-Net-Daemon noarch 0.48-5.el7 rhel 51 k perl-PlRPC noarch 0.2020-14.el7 rhel 36 k Transaction Summary

  1. Install 2 Packages (+8 Dependent packages)
  2. Total download size: 21 M
  3. Installed size: 107 M
  4. Is this ok [y/d/N]: y
  5. Downloading packages:
  6. --------------------------------------------------------------------------------
  7. Total 82 MB/s | 21 MB 00:00
  8. Running transaction check
  9. Running transaction test
  10. Transaction test succeeded
  11. Running transaction
  12. ………………省略部分输出信息………………
  13. Installed:
  14. mariadb.x86_64 1:5.5.35-3.el7 mariadb-server.x86_64 1:5.5.35-3.el7
  15. Dependency Installed:
  16. perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7
  17. perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7
  18. perl-DBD-MySQL.x86_64 0:4.023-5.el7
  19. perl-DBI.x86_64 0:1.627-4.el7
  20. perl-Data-Dumper.x86_64 0:2.145-3.el7
  21. perl-IO-Compress.noarch 0:2.061-2.el7
  22. perl-Net-Daemon.noarch 0:0.48-5.el7
  23. perl-PlRPC.noarch 0:0.2020-14.el7
  24. Complete!
  25. [root@linuxprobe ~]# systemctl start mariadb
  26. [root@linuxprobe ~]# systemctl enable mariadb
  27. ln -s '/usr/lib/systemd/system/mariadb.service' '/etc/systemd/system/multi-user.target.wants/mariadb.service'

Do not use the MariaDB database software program immediately after confirming that it has been installed and started successfully. I n order to ensure the security and functioning of the database, the database program needs to be initialized first. This initialization involves the following 5 steps.

Set the root administrator's password value in the database (note that the password is not the root administrator's password in the system, where the password value should be empty by default and you can press the enter key directly). S et the root administrator's proprietary password in the database. T he anonymous account is then deleted and the root administrator is used to log on to the database remotely to ensure the security of the business running on the database. D elete the default test database and cancel a series of access rights to the test database. R efresh the authorization list so that the initialization settings take effect immediately. For the above database initialization steps, Mr. Liu has made a simple comment next to the output information below to ensure that readers have a more intuitive understanding of what to enter:

[root@linuxprobe ~]# mysql_secure_installation /usr/bin/mysql_secure_installation: line 379: find_mysql_client: command not found 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): The current database password is empty, press the Enter key 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: Enter the database password to the root administrator RE-ENTER NEW Password: Enter the 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 (Delete anonymous accounts) ... 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 (Prohibition of the root administrator from logging in remote) ... 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 (Delete Test Database and cancel access to it)

  • Dropping test database... ... Success!
  • Removing privileges on test database... ... S uccess! R eloading the privilege tables will ensure that all changes made so far will take effect immediately. R eload privilege tables now? ( Y/n) y (refresh the authorization form for immediate effect after initialization) ... S uccess! C leaning up... A ll done! I f you've completed all of the above steps, your MariaDB installation should now be secure. T hanks for using MariaDB! I n many production environments, you need to use library-separated technologies (i.e., websites and databases are not on the same server), and if you need to have root administrators access the database remotely, you can set policies in the initialization operation above to allow root administrators to access them remotely. You will then need to set up a firewall to release access requests to the database service program, which by default occupies port 3306, and the service name is uniformly called mysql in the firewall policy:

The root@linuxprobe root@linuxprobe is ready for everything. N ow we will log in to the Maria DB database for the first time. Where the -u parameter is used to specify login as root administrator, and the -p parameter is used to verify the user's password value in the database.

(root@linuxprobe) mysql -u root -p Enter password: Enter the root administrator's password welcome to the MariaDB monitor in the database here. C ommands end with ; o r \g. Your MariaDB connection id is 5 Server version: 5.5.35-MariaDB MariaDB Server Copyright (c) 2000, 2013, Oracle, Monty Program Ab and others. T ype 'help; ' or '\h' for help. T ype '\c' to clear the current input statement. M ariaDB (none); when executing a database command after logging into the MariaDB database, you need to use a sign mark after the command (; A t the end, this is also the most significant difference from the Linux command. Y ou need to get used to this setting of database commands. Here's a command to see what databases are currently in the database management system:

MariaDB [(none)]> SHOW databases; + --------------------+ | D atabase | + --------------------+ | i nformation_schema | | m ysql | | p erformance_schema | A fter -------------------- the 3 rows in set (0.01 sec) calf, the next step is to use the database command to change the password value of the root administrator in the database management system to linuxprobe. If you log out and then try to sign in, you'll be prompted for a failed access if you insist on entering your original password.

MariaDB [(none)]> SET password = PASSWORD('linuxprobe'); Query OK, 0 rows affected (0.00 sec) MariaDB (none) and exit Bye (root@linuxprobe) - mysql -u root -p Enter Password: Enter the root administrator's new password in the database HERE ERROR 1045 (28000): Access denied for user 'root' s 'localhost' (US: YES)