Use Apt-get to install mysql+ security optimization on Ubuntu

Source: Internet
Author: User

0. Description

The advantage of using the Apt-get installation is that you do not have to solve the dependencies between the software itself, basically apt executes, the software is installed, the following describes the use of apt method to install MySQL, but also describes the security optimization after the installation is complete.

Note: The following actions are taken as a demonstration with the newly installed Ubuntu 15.10 .



1. Install MySQL using apt

    • To install the MySQL database:

Note: During the installation process, you will be asked to set the administrator user password of the MySQL database several times, we do not set it here first. (Press OK directly when the page that you want to set up appears.) )

[Email protected]:~$ sudo apt-get install mysql-server mysql-client Libmysqlclient-dev

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

    • To turn on the MySQL service:

[Email protected]:~$ sudo service MySQL start
    • Log in to the MySQL database:

[Email protected]:~$ mysql-u rootwelcome to the MySQL monitor. Commands End With;  or \g.your MySQL connection ID is 7Server version:5.6.28-0ubuntu0.15.10.1 (Ubuntu) Copyright (c), Oracle and/or its affiliates. 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>

Since the password is not set for the root user of the MySQL database at the time of installation, it is not possible to enter the MySQL database without entering the password.


In fact, if the non-production environment requirements, such as the above using Apt-get 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 '; mysql& Gt Update mysql.user Set password = password (' 123456 ') where user = ' root '; Query OK, 4 rows Affected (0.00 sec) rows Matched:4 changed:4 warnings:0mysql> flush privileges; Query OK, 0 rows Affected (0.00 sec)

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

When you're done, check your 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 | |  root             | ::1        | *6bb4837eb74329105ee4568dda7dc67ed2ca2ad9 | |  debian-sys-maint | localhost | *6a368d614e978d78292fc3257d3958c6a7b241ef |+---- --------------+-----------+-------------------------------------------+5 rows in set  (0.00  SEC)


It is important to note that since we have already set the password for the root user, please specify the-p parameter at the next login:

[Email protected]:~$ mysql-u root-penter Password:

The password is the ' 123456 ' we set.


(2) 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, 0 rows Affected (0.00 sec) mysql> flush privileges; Query OK, 0 rows Affected (0.00 sec)


OK, in this case, using Apt-get to install MySQL and MySQL basic security optimization is complete, should not have 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/1748704

Use Apt-get to install mysql+ security optimization on Ubuntu

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.