mariadb - install

DB/MariaDB 2014. 7. 20. 16:12


Install MariaDB 10 on Fedora 23/22, CentOS/RHEL 7.1/6.7/5.11


MariaDB is a binary drop in replacement for MySQL database server. This means that for most cases, you can just uninstall MySQL and install MariaDB and you are good to go.

Why MariaDB?

  • MariaDB is totally open source version of MySQL
  • It works just like MySQL and is compatible with MySQL setups
  • Fedora and Red Hat/CentOS is moving to use MariaDB from Fedora 19/RHEL 7/CentOS 7 versions

This is guide, howto install or upgrade MariaDB 10.0.22 (or 10.1.8 or 5.5.46) on Fedora 23/22/21/20, CentOS 7.1/6.7/5.11 and Red Hat (RHEL) 7.1/6.7/5.11. Installing MariaDB is almost same process than install MySQL.

Note: If you are moving from MySQL, then make sure that you backup (dump and copy) your database and configs. And if upgrading from earlier versions, then remember run mysql_upgrade command. And if you uninstall MySQL, then remember restore /etc/my.cnf after installation, like:

Install MariaDB/MariaDB-server 10.1.8/10.0.28/5.5.46 on Fedora 23/22/21/20, CentOS 7.1/6.7/5.11, Red Hat (RHEL) 7.1/6.7/5.11

1. Change root user

2. Install MariaDB repository

Following commands are just shortcut to install original MariaDB YUM repos, alternatively you could use MariaDB repository configuration tool.

Fedora 21/20

Note: currently only option for Fedora 23/22 users is MariaDB 10.0 and not additional repos needed.

CentOS 7/6/5

Red Hat (RHEL) 7/6/5

3. Update or Install MariaDB 10.0/10.1/5.5

Fedora 23/22

Fedora 21/20, CentOS 7.1/6.7/5.11 and Red Hat (RHEL) 7.1/6.7/5.11

4. Start MariaDB server and autostart MariaDB on boot

Fedora 23/22

Fedora 21/20, CentOS 7.1/6.7/5.11 and Red Hat (RHEL) 7.1/6.7/5.11

5. MariaDB (MySQL) Secure Installation

  • Set (Change) root password
  • Remove anonymous users
  • Disallow root login remotely
  • Remove test database and access to it
  • Reload privilege tables

Start MariaDB (MySQL) Secure Installation with following command

Output:

Note: If you don’t want some reason, do a “MySQL Secure Installation” then at least it’s very important to change the root user’s password

6. Connect to MySQL database (localhost) with password

7. Create Database, Create MySQL User and Enable Remote Connections to MySQL Database

This example uses following parameters:

  • DB_NAME = webdb
  • USER_NAME = webdb_user
  • REMOTE_IP = 10.0.15.25
  • PASSWORD = password123
  • PERMISSIONS = ALL

Enable Remote Connection to MariaDB Server –> Open MySQL Port (3306) on Iptables Firewall (as root user again)

1. CentOS/Red Hat (RHEL) 6.7/5.11

1.1 Edit /etc/sysconfig/iptables file:

1.2 Add following INPUT rule:

1.3 Restart Iptables Firewall:

2. Fedora 23/22/21/20 and CentOS/Red Hat (RHEL) 7.1

2.1 List Your Active Firewalld Zones

Example output:

2.2 Add New Rule to Firewalld

You might have active zone like public, FedoraWorkstation, FedoraServer.

2.3 Restart firewalld.service

3. Test remote connection




source - http://www.if-not-true-then-false.com/2013/install-mariadb-on-fedora-centos-rhel/








Install MariaDB 5.5.37 on Fedora 20/19, CentOS/Red Hat (RHEL) 6.5/5.10


MariaDB is a binary drop in replacement for MySQL database server. This means that for most cases, you can just uninstall MySQL and install MariaDB and you are good to go.

Why MariaDB?

  • MariaDB is totally open source version of MySQL
  • It works just like MySQL and is compatible with MySQL setups
  • Fedora and Red Hat/CentOS is moving to use MariaDB from Fedora 19/RHEL 7/CentOS 7 versions

This is guide, howto install or upgrade MariaDB 5.5.37 on Fedora 20/19/18/17, CentOS 6.5/5.10 and Red Hat (RHEL) 6.5/5.10. Installing MariaDB is almost same process than install MySQL.

Note: If you are moving from MySQL, then make sure that you backup (dump and copy) your database and configs. And if upgrading from earlier versions, then remember run mysql_upgrade command. And if you uninstall MySQL, then remember restore /etc/my.cnf after installation, like:

mv -vi /etc/my.cnf.rpmsave /etc/my.cnf

Install MariaDB/MariaDB-server 5.5.37 on Fedora 20/19/18/17, CentOS 6.5/5.10, Red Hat (RHEL) 6.5/5.10

1. Change root user

su -
## OR ##
sudo -i

2. Install MariaDB repository

Fedora

Note: not needed/available on Fedora 20! Fedora 20 MariaDB version, is currently 5.5.33a.

## Fedora 19/18/17 MariaDB 5.5 ##
wget -O /etc/yum.repos.d/MariaDB.repo http://mariadb.if-not-true-then-false.com/fedora/$(rpm -E %fedora)/$(uname -i)/5
 
## Fedora 19/18/17 MariaDB 10.0 ##
wget -O /etc/yum.repos.d/MariaDB.repo http://mariadb.if-not-true-then-false.com/fedora/$(rpm -E %fedora)/$(uname -i)/10

CentOS

## CentOS 6/5 MariaDB 5.5 ##
wget -O /etc/yum.repos.d/MariaDB.repo http://mariadb.if-not-true-then-false.com/centos/$(rpm -E %centos)/$(uname -i)/5
 
## CentOS 6/5 MariaDB 10.0 ##
wget -O /etc/yum.repos.d/MariaDB.repo http://mariadb.if-not-true-then-false.com/centos/$(rpm -E %centos)/$(uname -i)/10

Red Hat (RHEL)

## Red Hat (RHEL) 6/5 MariaDB 5.5 ##
wget -O /etc/yum.repos.d/MariaDB.repo http://mariadb.if-not-true-then-false.com/rhel/$(rpm -E %rhel)/$(uname -i)/5
 
## Red Hat (RHEL) 6/5 MariaDB 10.0 ##
wget -O /etc/yum.repos.d/MariaDB.repo http://mariadb.if-not-true-then-false.com/rhel/$(rpm -E %rhel)/$(uname -i)/10

Remember check your

3. Update or Install MariaDB 5.5.37

Fedora 20

yum install mariadb mariadb-server

Fedora 19/18/17, CentOS 6.5/5.10 and Red Hat (RHEL) 6.5/5.10

yum install MariaDB MariaDB-server

4. Start MariaDB server and autostart MariaDB on boot

Fedora 20

systemctl start mariadb.service ## use restart after update
 
systemctl enable mariadb.service

Fedora 19/18/17, CentOS 6.5/5.10 and Red Hat (RHEL) 6.5/5.10

service mysql start ## use restart after update
## OR ##
/etc/init.d/mysql start ## use restart after update
 
chkconfig --levels 235 mysql on

5. MariaDB (MySQL) Secure Installation

  • Set (Change) root password
  • Remove anonymous users
  • Disallow root login remotely
  • Remove test database and access to it
  • Reload privilege tables

Start MariaDB (MySQL) Secure Installation with following command

/usr/bin/mysql_secure_installation

Output:

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

Note: If you don’t want some reason, do a “MySQL Secure Installation” then at least it’s very important to change the root user’s password

mysqladmin -u root password [your_password_here]
 
## Example ##
mysqladmin -u root password myownsecrectpass

6. Connect to MySQL database (localhost) with password

mysql -u root -p
 
## OR ##
mysql -h localhost -u root -p

7. Create Database, Create MySQL User and Enable Remote Connections to MySQL Database

This example uses following parameters:

  • DB_NAME = webdb
  • USER_NAME = webdb_user
  • REMOTE_IP = 10.0.15.25
  • PASSWORD = password123
  • PERMISSIONS = ALL
## CREATE DATABASE ##
MariaDB [(NONE)]> CREATE DATABASE webdb;
 
## CREATE USER ##
MariaDB [(NONE)]> CREATE USER 'webdb_user'@'10.0.15.25' IDENTIFIED BY 'password123';
 
## GRANT PERMISSIONS ##
MariaDB [(NONE)]> GRANT ALL ON webdb.* TO 'webdb_user'@'10.0.15.25';
 
##  FLUSH PRIVILEGES, Tell the server TO reload the GRANT TABLES  ##
MariaDB [(NONE)]> FLUSH PRIVILEGES;

Enable Remote Connection to MariaDB Server –> Open MySQL Port (3306) on Iptables Firewall (as root user again)

1. CentOS/Red Hat (RHEL)

1.1 Edit /etc/sysconfig/iptables file:

nano -w /etc/sysconfig/iptables

1.2 Add following INPUT rule:

-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT

1.3 Restart Iptables Firewall:

service iptables restart
## OR ##
/etc/init.d/iptables restart

2. Fedora

2.1 Add New Rule to Firewalld

firewall-cmd --permanent --zone=public --add-service=mysql
 
## OR ##
 
firewall-cmd --permanent --zone=public --add --port=3306/tcp

2.2 Restart firewalld.service

systemctl restart firewalld.service

3. Test remote connection

Access following address, with your browser. http://your.domain/test.php












source - http://www.if-not-true-then-false.com/2010/install-mysql-on-fedora-centos-red-hat-rhel/








# vi /etc/my.cnf

#

# This group is read both both by the client and the server

# use it for options that affect everything

#

[client-server]


#

# This group is read by the server

#

[mysqld]

# Disabling symbolic-links is recommended to prevent assorted security risks

symbolic-links=0


init_connect=SET character_set_server=utf8

init_connect=SET collation_connection=utf8_general_ci

init_connect=SET NAMES utf8

character-set-server=utf8

collation-server=utf8_general_ci


#

# include all files from the config directory

#

!includedir /etc/my.cnf.d


[client]

default-character-set=utf8


[mysql]

default-character-set=utf8


[mysqldump]

default-character-set=utf8




'DB > MariaDB' 카테고리의 다른 글

mariadb - Activating the General Query Log  (0) 2015.06.10
mariadb - install  (0) 2014.07.20
Posted by linuxism

댓글을 달아 주세요