Use Yum to install mysql+ security optimizations on CentOS

Source: Internet
Author: User

0. Description

The advantage of using the Yum installation is that you don't have to solve the dependencies between the software yourself, basically yum finishes, and the software is installed, and the Yum approach to installing MySQL is described below, as well as the security optimizations after the installation is complete.

Note: The following actions are demonstrated with the newly installed CentOS 6.5来.



1. Install MySQL with yum


    • To see if MySQL is already installed:

[Email protected]]# yum List installed | grep MySQL

If you specify the installation of the MySQL database when installing CentOS, there will be a display, here I did not install MySQL.

    • To install the MySQL database:

[[email protected] ~]# yum-y install mysql-server mysql mysql-devel

Note on your system to see the message after the installation is successful.

    • To view the installed MySQL information:

[[email protected] ~]# yum list installed | grep mysqlmysql.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 
    • To turn on the MySQL service:

[[Email protected] ~]# service mysqld startstarting mysqld: [OK]
    • Log in to the MySQL database:

[Email protected] ~]# Mysqlwelcome to the MySQL Monitor. Commands End With; or \g.your MySQL connection ID is 4Server version:5.1.73 Source distributioncopyright (c), +, Oracle and/or its a Ffiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names trademarks of their respectiveowners. Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement.mysql>


In fact, if the non-production environment requirements, like the above using yum simple installation can be, of course, if used in the production environment, then it is recommended to use the source code installation.



2.MySQL Security Optimization


As for why to security optimization, you can read the blogger written by the source of the installation of MySQL blog: "On the CentOS source installation mysql+ installation problem solving + security optimization"

The following steps are given directly to the operation. (Note: To ensure that the MySQL service is turned on, the method is already given above)


(1) Create a password for the root user

[[email protected] ~]# mysql-u rootmysql> update mysql.user Set password = password (' 123456 ') where user = ' root '; Query OK, 3 Rows Affected (0.00 sec) rows Matched:3 changed:3 warnings:0mysql> flush privileges; Query OK, 0 rows Affected (0.00 sec)

The password ' 123456 ' is created for the root user.


(2) Delete anonymous users

    • First log in to MySQL with the password you just created:

[Email protected] ~]# mysql-u root-penter password:mysql>
    • To delete an anonymous user:

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, where the ' leaf ' is my hostname and can be operated according to your actual situation.


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

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 begins with test

The operation is as follows:

Mysql> Delete from the 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, in this case, using Yum to install MySQL and MySQL basic security optimization is complete, there should be no too much problem.


This article is from the "fragrant fluttering leaves" blog, please make sure to keep this source http://xpleaf.blog.51cto.com/9315560/1748625

Use Yum to install mysql+ security optimizations on CentOS

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.