Install MySQL and Security Optimization Using yum on CentOS

Source: Internet
Author: User

Install MySQL and Security Optimization Using yum on CentOS

0. Description

The advantage of yum installation is that you don't have to solve the dependency problem between software by yourself. Basically, after yum is executed, the software is installed. The following describes how to install MySQL using yum, the security Optimization after installation is also introduced.

Note: The following operations are demonstrated by the newly installed CentOS 6.5.

Install MySQL 5.6 with the source code in CentOS 7

How to install and configure MySQL5.7.3.0

Install MySQL in Ubuntu 14.04

MySQL authoritative guide (original book version 2nd) Clear Chinese scan PDF

Ubuntu 14.04 LTS install LNMP Nginx \ PHP5 (PHP-FPM) \ MySQL

Build a MySQL Master/Slave server in Ubuntu 14.04

Build a highly available distributed MySQL cluster using Ubuntu 12.04 LTS

Install MySQL5.6 and Python-MySQLdb in the source code of Ubuntu 12.04

MySQL-5.5.38 universal binary Installation

1. Use yum to install MySQL

  • Check whether MySQL has been installed:

1 [root@leaf]# yum list installed | grep mysql

If you specify to install MySQL database when installing CentOS, it will be displayed. I have not installed MySQL here.

  • Install MySQL database:

1 [root@leaf ~]# yum -y install mysql-server mysql mysql-devel

Check the prompt message after successful installation on your system.

  • View the installed MySQL information:

12345 [root@leaf ~]# yum list installed | grep mysql mysql.x86_64            5.1.73-5.el6_6  @base                                    mysql-devel.x86_64      5.1.73-5.el6_6  @base                                    mysql-libs.x86_64       5.1.73-5.el6_6  @base                                    mysql-server.x86_64     5.1.73-5.el6_6  @base
  • Start the MySQL service:

12 [root@leaf ~]# service mysqld start Starting mysqld:                                           [  OK  ]
  • Log on to the MySQL database:

1234567891011121314 [root@leaf ~]# mysql Welcome to the MySQL monitor.  Commands end with ; or \g. Your MySQL connection id is 4 Server version: 5.1.73 Source distribution   Copyright (c) 2000, 2013, 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.   mysql>

In fact, if it is not required by the production environment, use yum for simple installation as above. Of course, if it is used in the production environment, we recommend that you use the source code for installation.

2. MySQL Security Optimization

For more information about the security optimization, see the blog post titled installing MySQL with source code: Solution to the Problem of installing MySQL with source code on CentOS and Security optimization.

The following describes the procedure. (Note: Make sure that the MySQL service is enabled. The above method is provided)

(1) create a password for the root user

1234567 [root@leaf ~]# mysql -u root mysql> update mysql.user set password = password('123456') where User = 'root'; Query OK, 3 rows affected (0.00 sec) Rows matched: 3  Changed: 3  Warnings: 0   mysql> flush privileges; Query OK, 0 rows affected (0.00 sec)

The above Code creates the password '000000' for the root user '.

(2) Delete Anonymous Users

  • Log on to MySQL with the password you just created:

1234 [root@leaf ~]# mysql -u root -p Enter password:   mysql>
  • Delete Anonymous Users:

1234567 mysql> DROP USER ''@'localhost'; Query OK, 0 rows affected (0.00 sec)   mysql> DROP USER ''@'leaf';      Query OK, 0 rows affected (0.00 sec) mysql> flush privileges; Query OK, 0 rows affected (0.00 sec)

Note the 'leaf' of the second Delete statement. Here, 'leaf' is my host name and can be operated according to your actual situation.

After completing step (1) (2) above, check the current account information:

123456789 mysql> select User, Host, Password from mysql.user;  +------+-----------+-------------------------------------------+ | User | Host      | Password                                  | +------+-----------+-------------------------------------------+ | root | localhost | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 | | root | leaf      | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 | | root | 127.0.0.1 | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 | +------+-----------+-------------------------------------------+ 3 rows in set (0.00 sec)

(3) Delete the test database or the database whose name starts with test.

The procedure is as follows:

12345678 mysql> delete from mysql.db where db like 'test%'; Query OK, 2 rows affected (0.00 sec)   mysql> drop database test; Query OK, 0 rows affected (0.00 sec)   mysql> flush privileges; Query OK, 0 rows affected (0.00 sec)

OK. Here, you can use yum to install MySQL and basic security Optimization of MySQL. There should be no major problems.

This article permanently updates the link address:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.