Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install and configure MariaDB MySQL on CentOS system

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly tells you briefly how to install and configure MariaDB MySQL on the CentOS system. You can check the relevant professional terms on the Internet or find some related books to supplement them. We will not dabble here, so let's go straight to the topic. I hope this article on how to install and configure MariaDB MySQL on the CentOS system can bring you some practical help.

MariaDB MySQL software package

Here are three main MariaDB packages:

Mariadb-5.5.52-1.el7.x86_64-this contains several MySQL client programs and utilities.

Mariadb-server-5.5.52-1.el7.x86_64-this is the main MariaDB MySQL database cloud server.

Mariadb-libs-5.5.52-1.el7.x86_64-contains the shared libraries required for the client program interface.

# yum info mariadb-serverLoaded plugins: fastestmirrorLoading mirror speeds from cached hostfile * base: repos-va.psychz.net * extras: linux.cc.lehigh.edu * updates: mirror.us.leaseweb.netAvailable PackagesName: mariadb-serverArch: x86_64Epoch: 1Version: 5.5.52Release: 1.el7Size: 11 MRepo: base/7/x86_642. Install MariaDB MySQL CVM

Use yum install to install the MariaDB MySQL CVM package shown below.

# yum install mariadb-server

At this point, mariadb-server and the following dependent packages have been installed on this CVM.

Mariadb-server.x86_64 1mariadb-server.x86_64 5.5.52-1.el7mariadb-libs.x86_64 1mer 5.5.52-1.el7mariadb.x86_64 1V 5.5.52-1.el7libaio.x86_64 0v 0.3.109-13.el7perl-DBD-MySQL.x86_64 0v 4.023-5.el7perl-DBI.x86_64 0v 1.627-4.el7perl-Compress-Raw-Bzip2.x86_64 0v 2.061-3.el7perl-Compress-Raw -Zlib.x86_64 1 5.el7perl-plRPC.noarch 2.061-4.el7perl-Data-Dumper.x86_64 0v 2.145-3.el7perl-IO-Compress.noarch 0v 2.061-2.el7perl-Net-Daemon.noarch 0v 0.48-5.el7perl-plRPC.noarch 0v 0.2020-14.el7

Verify that three important MariaDB mysql packages have been installed.

# rpm-qa | grep-I maria mariadb-5.5.52-1.el7.x86_64 mariadb-server-5.5.52-1.el7.x86_64 mariadb-libs-5.5.52-1.el7.x86_643. Start the MariaDB database

As shown below, the mariadb database cloud server module has been loaded but has not been started.

# systemctl status mariadb? Mariadb.service-MariaDB database server Loaded: loaded (/ usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled) Active: inactive (dead)

Start the MariaDB mysql CVM using systemctl, as follows:

# systemctl start mariadb

Verify the systemctl status to ensure that the mariadb database cloud server has been started successfully

# systemctl status mariadb? Mariadb.service-MariaDB database server Loaded: loaded (/ usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled) Active: active (running) since Thu 2017-06-26 18:26:35 UTC 13s ago Process: 4049 ExecStartPost=/usr/libexec/mariadb-wait-ready $MAINPID (code=exited, status=0/SUCCESS) Process: 3969 ExecStartPre=/usr/libexec/mariadb-prepare-db-dir% n (code=exited Status=0/SUCCESS) Main PID: 4048 (mysqld_safe) CGroup: / system.slice/mariadb.service +-4048 / bin/sh / usr/bin/mysqld_safe-- basedir=/usr +-4206 / usr/libexec/mysqld-- basedir=/usr-- datadir=/var/lib/mysql-- plugin-dir=/usr/lib64/mysql/plugin-- log-error=/var/log/mariadb/ma...Aug 15 15:20:30 deploy mariadb-prepare-db -dir [3969]: The latest information about MariaDB is available at http://mariadb.org/.Aug 15 15:20:30 deploy mariadb-prepare-db-dir [3969]: You can find additional information about the MySQL part at:Aug 15 15:20:30 deploy mariadb-prepare-db-dir [3969]: http://dev.mysql.comAug 15 15:20:30 deploy mariadb-prepare-db-dir [3969]: Support MariaDB development by buying support/new features from MariaDBAug 15 15:20:30 deploy mariadb-prepare-db-dir [3969]: Corporation Ab. You can contact us about this at sales@mariadb.com.Aug 15 15:20:30 deploy mariadb-prepare-db-dir [3969]: Alternatively consider joining our community based development effort:Aug 15 15:20:30 deploy mariadb-prepare-db-dir [3969]: http://mariadb.com/kb/en/contributing-to-the-mariadb-project/Aug 15 15:20:30 deploy mysqld_safe [4048]: 170601 15:20:33 mysqld_safe Logging to'/ var/log/mariadb/mariadb.log' .Aug 15 15:20:30 deploy mysqld_safe [4048]: 170601 15:20:33 mysqld_safe Starting mysqld daemon with databases from / var/lib/mysqlAug 15 15:20:35 deploy systemd [1]: Started MariaDB database server.

4. Connect and verify MariaDB Server

Use the mysql command shown below to connect to the database using the root user of mysql

# mysql-u rootWelcome to the MariaDB monitor. Commands end with; or\ g.Your MariaDB connection id is 2Server version: 5.5.52-MariaDB MariaDB Server Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others. Type 'help;' or'\ h' for help. Type'\ c'to clear the current input statement.MariaDB [(none)] >

The following show database command displays the default mysql database.

MariaDB [(none)] > show databases;+-+ | Database | +-+ | information_schema | | mysql | | performance_schema | | test | +-+

5. Perform MariaDB Post Installation steps

As you can see from the above, by default, the installation does not assign any passwords to the MySQL root account.

To set the mysql root user password and perform other security configurations on the database, execute the mysql_secure_installation script shown below.

# / usr/bin/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 currentpassword for the root user. If you've just installed MariaDB, andyou haven't set the root password yet, the password will be blank,so you should just press enter here.

Since this is the first time we have run this script, no password has been assigned to the mysql root account. So, please 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 MariaDBroot user without the proper authorisation.

At this stage, say "y" to assign a password to the MySQL root account. Then enter the password.

Please note that this mysql root account is different from the linux root account. So, we set the password for the mysql root account here, which has nothing to do with the Linux root account.

Set root password? [Y/n] yNew password: Re-enter new password: Password updated successfully!Reloading privilege tables.. ... Success!

As part of the default installation, mysql installs anonymous users and can log in to the database without a real user. So we should delete this user.

Remove anonymous users? [Y/n] y... Success! Normally, root should only be allowed to connect from 'localhost'. Thisensures that someone cannot guess at the root password from the network.

As you can imagine, the mysql root account will be able to access all mysql databases. Therefore, it is very important to keep this safe. In addition, we should ensure that remote clients from other cloud servers are not allowed to connect using this mysql root account.

In contrast, only the local host (where the mysql CVM is installed) can connect using the root account. So we should disable root login remotely.

Disallow root login remotely? [Y/n] y... Success!

This is the default test database, and we should delete it.

Remove test database and access to it? [YBO] y-Dropping test database... ... Success!-Removing privileges on test database... ... Success!

Enter y here to ensure that all changes we make 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 MariaDBinstallation should now be secure. Thanks for using MariaDB

6. Verify MySQL root access

Now, if you connect to a Mysql that does not have a root password, you will receive the following access denied error message.

# mysql-u rootERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

To specify a password, use the-p option, as shown below. This prompts the user for a password.

# mysql-u root-pEnter password:

In addition, you can see from the following show databases command that the test database has now been deleted.

MariaDB [(none)] > show databases;+-+ | Database | +-+ | information_schema | | mysql | | performance_schema | +-+

If you want to pass the password on the mysql command line, specify it next to the-p option, as shown below.

# mysql-u root-pMySecurePassword

Note: there is no space between-p and the password. This can cause some confusion because we have spaces between-u and username. However, there is no space between-p and the password.

CentOS system how to install and configure MariaDB MySQL will first tell you here, for other related issues you want to know can continue to pay attention to our industry information. Our section will capture some industry news and professional knowledge to share with you every day.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report