MySQL 5.7 : Install2017/01/17 |
Install MySQL 5.7 to configure Database Server.
|
|
[1] | It's possible to install from CentOS SCLo Software Collections. It's OK to install it even if MariaDB is already installed because MySQL 5.7 is located on another PATH. |
# install from SCLo [root@www ~]# yum --enablerepo=centos-sclo-rh -y install rh-mysql57-mysql-server
|
[2] | Packages from Software Collections are installed uder the /opt directory. To use it, Load environment variables like follows. |
# load environment variables [root@www ~]# scl enable rh-mysql57 bash
[root@www ~]#
[root@www ~]# mysql -V mysql Ver 14.14 Distrib 5.7.16, for Linux (x86_64) using EditLine wrapper which mysql /opt/rh/rh-mysql57/root/usr/bin/mysql |
[3] | To enable MySQL 5.7 automatically at login time, configure like follows. |
[root@www ~]#
vi /etc/profile.d/rh-mysql57.sh # create new source /opt/rh/rh-mysql57/enable export X_SCLS="`scl enable rh-mysql57 'echo $X_SCLS'`" |
[4] | Enable MySQL 5.7 and Configure initial settings. |
[root@www ~]#
vi /etc/opt/rh/rh-mysql57/my.cnf.d/rh-mysql57-mysql-server.cnf # add follows within [mysqld] section [mysqld]
character-set-server=utf8
mysql_secure_installation Securing the MySQL server deployment. Connecting to MySQL using a blank password. VALIDATE PASSWORD PLUGIN can be used to test passwords and improve security. It checks the strength of password and allows the users to set only those passwords which are secure enough. Would you like to setup VALIDATE PASSWORD plugin? # enable password quarity checking plugin or not Press y|Y for Yes, any other key for No: y There are three levels of password validation policy: LOW Length >= 8 MEDIUM Length >= 8, numeric, mixed case, and special characters STRONG Length >= 8, numeric, mixed case, special characters and dictionary file # choose password quarity level Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 2 Please set the password for root here. # set root password New password: Re-enter new password: By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL 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 Remove anonymous users? (Press y|Y for Yes, any other key for No) : 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 Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y Success. By default, MySQL 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 Remove test database and access to it? (Press y|Y for Yes, any other key for No) : 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 Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y Success. All done! # connect to MySQL with root [root@www ~]# mysql -u root -p Enter password: # the password you set above Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 4 Server version: 5.7.16 MySQL Community Server (GPL) Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. # show user list mysql> select user,host from mysql.user; +-----------+-----------+ | user | host | +-----------+-----------+ | mysql.sys | localhost | | root | localhost | +-----------+-----------+ 2 rows in set (0.00 sec) # show database list mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | +--------------------+ 4 rows in set (0.00 sec)mysql> exit Bye |
[5] | If Firewalld is running and also MySQL is used from remote Hosts, allow service like follows. MySQL uses 3306/TCP. |
[root@www ~]# firewall-cmd --add-service=mysql --permanent success [root@www ~]# firewall-cmd --reload success |
Sponsored Link |