Passa ai contenuti principali

Linux CentOS 7 - Installing MariaDB

Linux CentOS 7 - Installing MariaDB

Install MariaDB and make sure the databases can be accessed as user root by entering a password; the databases must by accessible only locally.

On system1

Install packages for MariaDB
# yum install mariadb* -y


Enable and start the process
# systemctl enable mariadb && systemctl start mariadb

Run the installation wizard (script) and anwer the quesitons



# 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.

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
 ... 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] 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!

Adjust the firewall
# firewall-cmd --permanent --add-service=mysql
# firewall-cmd --reload

Access the database
# mysql -u root -p

Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 7
Server version: 5.5.56-MariaDB MariaDB Server

Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> exit

Edit the configuration file
# vim /etc/my.cnf

Insert the line

skip-networking = 1

at the end of the [mysqld] stanza.



Restart the process for the changes to take effect.
# systemctl restart mariadb





Commenti

Post popolari in questo blog

Linux CentOS 7 - Mounting the iso file as a CD-ROM

Linux CentOS 7 - Mounting the iso file as a CD-ROM in a repo Mount the iso file as a CD-ROM in a repository. Provided your iso file contains the complete operative system, this allows you to disable the default repositories and mirrors and install all required packages without downloading them from the internet. In other words you can work off-line. On system1 and/or system2 Edit the repo file vim /etc/yum.repos.d/CentOS-CD.repo [CentOS-CD] name =  CD ROM baseurl = file:///media/CentOS gpgcheck = 0 enabled = 1 Mount the iso file as a CD-ROM in a repository. Make a mount point mkdir /media/CentOS Edit the fstab file /dev/cdrom     /media/CentOS   iso9660   loop 0 0 mont -a Verify df -Th it must return the /dev/loop0 disk yum repolist it must show the repositories contained in the iso file.

Linux CentOS 7 - Configuring a cache-only DNS

Linux CentOS 7 - Configuring a cache-only DNS Configure a cache only DNS server which forwards requests to the well known Google DNS server. On system1 Install the unbound package # yum install -y unbound Enable and start the service # systemctl enable unbound && systemctl start unbound Adjust the configuration file # vim /etc/unbound/unbound.conf interface: 0.0.0.0                       ## all interfaces access-control: 0.0.0.0/0 allow ## from all networks forward-zone      name: "."                              ## from any domain      forward-addr: 8.8.8.8           ## DNS server towards which all requests will be forwarded Check configuration  # unbound-checkconf Modify the DNS server on the interface configuration # vim /etc/sysconfig/network-scripts/ifc...

Linux CentOS 7 - Basic scripting

Linux CentOS 7 - Basic scripting Configure a bash script called  foo.sh; this script reads an input parameter: if the input is "A", it returns "B"; if the input is "B", it returns "A"; otherwise it shows the message "usage foo.sh A|B" On system1 Edit the file: # vim /root/foo.sh #!/bin/bash if [ "$1" == "A" ]; then echo "B" elif [ "$1" == "B" ]; then echo "A"             e lse echo "/root/foo.sh A|B" fi Change the permissions to make it executable by all; # chmod a+x foo.sh Test it: # ./foo.sh A B Configure a script called makeusers.sh which reads a list of users from a file and creates those users with the /bin/false shell;   On system 1 Edit the script vim makeusers.sh #!/bin/bash if [ $# = 0 ]; then echo "usage makeusers.sh <users file>" exit 1 elif [ -f $1 ]; then for i in `cat $1`; do usera...