Tuesday 14 February 2017

How To Install MySQL5.7 on ubuntu 14.04 Linux Using APT

Before installing new packages always take the backup of current datadir and remove the old packages using below commands if present:

To remove mysql completely from your system Just type in terminal
shell> sudo apt-get purge mysql-server mysql-client mysql-common mysql-server-core-5.5 mysql-client-core-5.5
OR
shell> sudo apt-get remove --purge mysql*

shell> sudo rm -rf /etc/mysql /var/lib/mysql
shell> sudo apt-get autoremove
shell> sudo apt-get autoclean

Steps for a Fresh Installation of MySQL:

Adding the MySQL APT Repository

First, add the MySQL APT repository to your system's software repository list. Follow below steps:
  1. Go to the download page for the MySQL APT repository at http://dev.mysql.com/downloads/repo/apt/.
  2. Install the downloaded release package with the following command, replacing version-specific-package-name with the name of the downloaded package (preceded by its path, if you are not running the command inside the folder where the package is):
    shell> sudo dpkg -i /PATH/version-specific-package-name.deb
    
    For example, we are using mysql-apt-config_0.8.1-1_all.deb package, the command is:
    shell> sudo dpkg -i mysql-apt-config_0.8.1-1_all.deb
    
    Note that the same package works on all supported Debian and Ubuntu platforms.
  3. During the installation of the package, you will be asked to choose the versions of the MySQL server and other components that you want to install. If you are not sure which version to choose, do not change the default options selected for you. You can also choose none if you do not want a particular component to be installed. After making the choices for all components, choose OK to finish the configuration and installation of the release package.
  • Choose MySQL Server 5.7 option and press enter:
  • Choose mysql-5.7 release and press enter:
  • Choose OK and press enter: 
  • You will again come on command prompt.
d. Update package information from the MySQL APT repository with the below command:
  1. shell> sudo apt-get update

Installing MySQL with APT

Install MySQL by the using below command:
shell> sudo apt-get install mysql-server
:::::::::::
:::::::::::
Do you want to continue? [Y/n] y
This installs the package for the MySQL server, as well as the packages for the client and for the database common files.
During the installation, there are two requests by the dialogue boxes:
  • Supply a password for the root user for your MySQL installation.
  • Press OK after taking DataDir backup or if it is a fresh installation:
  • Provide root password:
  • Provide root password again:

Starting and Stopping the MySQL Server
The MySQL server is started automatically after installation. You can check the status of the MySQL server with the following command:
  1. shell> sudo service mysql status
    Stop the MySQL server with the following command:
    shell> sudo service mysql stop
    To restart the MySQL server, use the following command:
    shell> sudo service mysql start

MySQL Secure installation for initial security:

  • mysql_secure_installation — Improve MySQL Installation Security

This program enables you to improve the security of your MySQL installation in the following ways:
  • You can set a password for root accounts.
  • You can remove root accounts that are accessible from outside the local host.
  • You can remove anonymous-user accounts.
  • You can remove the test database (which by default can be accessed by all users, even anonymous users), and privileges that permit anyone to access databases with names that start with test_.
As of MySQL 5.7.2, mysql_secure_installation is an executable binary available on all platforms. Before 5.7.2, it was a script available for Unix and Unix-like systems.
Normal usage is to connect to the local MySQL server; invoke mysql_secure_installation without arguments:
shell> mysql_secure_installation
When executed, mysql_secure_installation prompts you to determine which actions to perform.
As of MySQL 5.7.2, mysql_secure_installation supports these additional features:
  • The validate_password plugin can be used for password strength checking. If the plugin is not installed, mysql_secure_installation prompts the user whether to install it. Any passwords entered later are checked using the plugin if it is enabled.
  • Most of the usual MySQL client options such as --host and --port can be used on the command line and in option files. For example, to connect to the local server over IPv6 using port 3307, use this command:
    shell> mysql_secure_installation --host=::1 --port=3307
For example below we are using 3310 port for mysql:
  • root@root@LSG-MySQLCITY:~# mysql_secure_installation --port=3310
    
    Securing the MySQL server deployment.
    
    Connecting to MySQL using a blank password.
    The 'validate_password' plugin is installed on the server.
    The subsequent steps will run with the existing configuration
    of the plugin.
    Please set the password for root here.
    
    New password:
    
    Re-enter new password:
    
    Estimated strength of the password: 100
    Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
    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? (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? (Press y|Y for Yes, any other key for No) : n
    
     ... skipping.
    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 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 now? (Press y|Y for Yes, any other key for No) : y
    Success.
    
    All done!
    root@LSG-MySQLCITY:~#

No comments:

Post a Comment