1. Delete the default database configuration file for CentOS 7.3
[root@localhost ~]# find -H /etc/ | grep my.c /etc/pki/tls/certs/make-dummy-cert /etc/pki/tls/certs/renew-dummy-cert /etc/my.cnf.d /etc/my.cnf.d/mysql-clients.cnf /etc/my.cnf [root@localhost ~]# rm -rf /etc/my.cnf /etc/my.cnf.d/ [root@localhost ~]# find -H /etc/ | grep my.c /etc/pki/tls/certs/make-dummy-cert /etc/pki/tls/certs/renew-dummy-cert
2. Uninstall system with mariadb-libs
query
[root@localhost ~]# rpm -qa|grep mariadb-libs mariadb-libs-5.5.52-1.el7.x86_64
uninstall
[root@localhost ~]# rpm -e mariadb-libs-5.5.52-1.el7.x86_64 --nodeps
Installation of related packages
[root@localhost ~]# yum -y install libaio [root@localhost ~]# yum -y install libaio-devel [root@localhost ~]# yum -y install bison [root@localhost ~]# yum -y install bison-devel [root@localhost ~]# yum -y install zlib-devel [root@localhost ~]# yum -y install openssl [root@localhost ~]# yum -y install openssl-devel [root@localhost ~]# yum -y install ncurses [root@localhost ~]# yum -y install ncurses-devel [root@localhost ~]# yum -y install libcurl-devel [root@localhost ~]# yum -y install libarchive-devel [root@localhost ~]# yum -y install boost [root@localhost ~]# yum -y install boost-devel [root@localhost ~]# yum -y install lsof [root@localhost ~]# yum -y install wget [root@localhost ~]# yum -y install gcc [root@localhost ~]# yum -y install gcc-c++ [root@localhost ~]# yum -y install make [root@localhost ~]# yum -y install cmake [root@localhost ~]# yum -y install perl [root@localhost ~]# yum -y install kernel-headers [root@localhost ~]# yum -y install kernel-devel [root@localhost ~]# yum -y install pcre-devel
3. Create a home directory to store package directories
[root@localhost ~]# mkdir soft [root@localhost ~]# cd soft
4. MariaDB Official Network Copy the Link Address of Source Packet and Download and Unzip
[root@localhost soft]# wget https://downloads.mariadb.org/interstitial/mariadb-10.2.6/source/mariadb-10.2.6.tar.gz [root@localhost soft]# ll total 66016 -rw-r--r--. 1 root root 67599197 May 14 19:13 mariadb-10.2.6.tar.gz [root@localhost soft]# tar -zxvf mariadb-10.2.6.tar.gz
5. Create MariaDB installation directory, database storage directory, user and directory
MariaDB installation directory is pre-booked here as / usr/local/mysql and data directory is / data/mysql. Users and directories should be established here, and maria user rights should be granted. The following operations are performed:
> Adding User Groups mysql [root@localhost soft]# groupadd -r mysql > Add users to groups mysql And it can be used without login. [root@localhost soft]# useradd -g mysql -s /sbin/nologin mysql > Establish maria Installation directory [root@localhost soft]# mkdir -p /usr/local/mysql > Create a database storage directory [root@localhost soft]# mkdir -p /data/mysql > Change the group to which the database store directory belongs mysql:mysql [root@localhost soft]# chown -R mysql:mysql /data/mysql
Perform compilation and installation
> Enter the decompressed source package folder [root@localhost soft]# cd mariadb-10.2.6 > Input compilation parameters cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ -DMYSQL_DATADIR=/data/mysql \ -DSYSCONFDIR=/etc \ -DWITHOUT_TOKUDB=1 \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_ARCHIVE_STPRAGE_ENGINE=1 \ -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \ -DWIYH_READLINE=1 \ -DWIYH_SSL=system \ -DVITH_ZLIB=system \ -DWITH_LOBWRAP=0 \ -DMYSQL_UNIX_ADDR=/tmp/mysql.sock \ -DDEFAULT_CHARSET=utf8 \ -DDEFAULT_COLLATION=utf8_general_ci > If compilation fails, delete CMakeCache.txt [root@localhost soft]# rm -f CMakeCache.txt > Let the command be re-executed, otherwise every time the file is read, the correct modification of the command is also an error. > cmake No problem. It can be compiled and installed. make && make install It's going to take a little longer. According to the personal machine, you can do something else.! [root@localhost soft]# make && make install > Execution is complete and installation is complete., But please note, This is just installation., Not started., Failure to start is equal to failure to install, It's useless and futile.?
6. Configure MariaDB
> Proceed to maria Installation directory [root@localhost ~]# cd /usr/local/mysql/ > Use maria User Execution Script, Install the database to the database storage directory [root@localhost mysql]# scripts/mysql_install_db --user=mysql --datadir=/data/mysql > Enter the following information: [root@localhost mysql]# scripts/mysql_install_db --user=mysql --datadir=/data/mysql Installing MariaDB/MySQL system tables in '/data/maria' ... OK To start mysqld at boot time you have to copy support-files/mysql.server to the right place for your system PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER ! To do so, start the server, then issue the following commands: './bin/mysqladmin' -u root password 'new-password' './bin/mysqladmin' -u root -h localhost.localdomain password 'new-password' Alternatively you can run: './bin/mysql_secure_installation' which will also give you the option of removing the test databases and anonymous user created by default. This is strongly recommended for production servers. See the MariaDB Knowledgebase at http://mariadb.com/kb or the MySQL manual for more instructions. You can start the MariaDB daemon with: cd '.' ; ./bin/mysqld_safe --datadir='/data/maria' You can test the MariaDB daemon with mysql-test-run.pl cd './mysql-test' ; perl mysql-test-run.pl Please report any problems at http://mariadb.org/jira The latest information about MariaDB is available at http://mariadb.org/. You can find additional information about the MySQL part at: http://dev.mysql.com Consider joining MariaDB's strong and vibrant community: https://mariadb.org/get-involved/
6. Copy maria configuration file to / etc directory
> Proceed to maria Installation directory [root@localhost ~]# cd /usr/local/maria/ > Copy support-files Files in directories my-large.cnf reach/etc Directory renamed my.cnf [root@localhost maria]# cp support-files/my-large.cnf /etc/my.cnf
7. Create startup scripts
[root@localhost maria]# cp support-files/mysql.server /etc/rc.d/init.d/mysqld
8. Start the mysqld service
[root@localhost maria]# /etc/rc.d/init.d/mysqld start
9. Configure environment variables to enter mysql in any directory
> Open and create new files [root@localhost maria]# vim /etc/profile.d/mysql.sh > Enter the following export PATH=$PATH:/usr/local/maria/bin/ > Save and exit :wq > Assign executable privileges to scripts [root@localhost maria]# chmod 0777 /etc/profile.d/mysql.sh > Conduct mysql.sh The directory where the script is located, And execute the script, Environmental variables with immediate effect [root@localhost maria]# source /etc/profile.d/mysql.sh
10. Initialize MariaDB
> Run MariaDB initialization script [root@localhost mysql]# ./bin/mysql_secure_installation > The following tips: Enter current password for root (enter for none): Enter the current root password (no input) Set root password? [Y/n] Set root password? (Yes/No) New password: Enter the new root password Re-enter new password: Confirm to enter root password Password updated successfully! Password updated successfully 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. By default, the MariaDB installation has an anonymous user. Allow anyone to log on to MariaDB without creating a user account. The goal is to test only and install more smoothly. You should delete their production environment before entering. Remove anonymous users? [Y/n] Delete anonymous users? (Yes/No) Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. Usually, root should only allow connections from localhost. This ensures that other users cannot guess the root password from the network. Disallow root login remotely? [Y/n] Root is not allowed to log in remotely? (Yes/No) 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. By default, MariaDB provides a database called "Test" that anyone can access. This is also for testing purposes only and should be deleted before entering the production environment. Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reloading the permission table will ensure that all changes made so far take effect immediately. Reload privilege tables now? [Y/n] Now reload the permission table (yes/no) All done! If you've completed all of the above steps, your MariaDB installation should now be secure. All done! If you have completed the above steps, MariaDB installation should be safe now. Thanks for using MariaDB! Thanks for using MariaDB!
All configurations after compiling and installing MariaDB
Last login: Sun Jun 11 13:50:59 2017 from 192.168.1.101 [root@localhost ~]# rm -rf /etc/my.cnf /etc/my.cnf.d/ [root@localhost ~]# cd /usr/local/mysql/ [root@localhost mysql]# scripts/mysql_install_db --user=mysql --datadir=/data/mysql/ Installing MariaDB/MySQL system tables in '/data/mysql/' ... OK To start mysqld at boot time you have to copy support-files/mysql.server to the right place for your system PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER ! To do so, start the server, then issue the following commands: './bin/mysqladmin' -u root password 'new-password' './bin/mysqladmin' -u root -h localhost.localdomain password 'new-password' Alternatively you can run: './bin/mysql_secure_installation' which will also give you the option of removing the test databases and anonymous user created by default. This is strongly recommended for production servers. See the MariaDB Knowledgebase at http://mariadb.com/kb or the MySQL manual for more instructions. You can start the MariaDB daemon with: cd '.' ; ./bin/mysqld_safe --datadir='/data/mysql/' You can test the MariaDB daemon with mysql-test-run.pl cd './mysql-test' ; perl mysql-test-run.pl Please report any problems at http://mariadb.org/jira The latest information about MariaDB is available at http://mariadb.org/. You can find additional information about the MySQL part at: http://dev.mysql.com Consider joining MariaDB's strong and vibrant community: https://mariadb.org/get-involved/ [root@localhost mysql]# cp support-files/my-large.cnf /etc/my.cnf [root@localhost mysql]# cp support-files/mysql.server /etc/rc.d/init.d/mysqld [root@localhost mysql]# /etc/rc.d/init.d/mysqld start Reloading systemd: [ OK ] Starting mysqld (via systemctl): [ OK ] [root@localhost mysql]# vim /etc/profile.d/mysql.sh [root@localhost mysql]# touch /etc/profile.d/mysql.sh [root@localhost mysql]# echo 'export PATH=$PATH:/usr/local/mysql/bin/' > /etc/profile.d/mysql.sh [root@localhost mysql]# chmod 0777 /etc/profile profile profile.d/ [root@localhost mysql]# chmod 0777 /etc/profile.d/mysql.sh [root@localhost mysql]# source /etc/profile.d/mysql.sh [root@localhost mysql]# mysql Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 10 Server version: 10.2.6-MariaDB-log Source distribution 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)]>