Ubuntu 16.04 install MySQL (5.7.18)

Source: Internet
Author: User

This is the branch page for http://www.cnblogs.com/EasonJim/p/7139275.html.

Before installing MySQL, you need to know the following:

1, MySQL various versions of the difference, reference: http://www.cnblogs.com/EasonJim/p/6274344.html

2, the official general point to the latest version of the download, if you want to download the previous version, such as the version of 5.5.x, there is a special entrance, reference: http://www.cnblogs.com/EasonJim/p/7147134.html

3, over time, the tutorial may be invalid, but the most standard and the latest tutorial is provided by the official, the entrance please refer to: http://www.cnblogs.com/EasonJim/p/7147198.html

Choice of installation Method:

0, the premise, regardless of which has the installation method must have the my.cnf file to have the understanding, the reference: http://www.cnblogs.com/EasonJim/p/7158466.html

1, in the installation before you need to pay attention to, there is an article http://www.cnblogs.com/EasonJim/p/6275863.html is to explain the installation of MySQL Mac, the installation method is based on the installation package pkg, there is an installation interface, After installation, the environment variables are automatically configured on the system settings and command line.

2, for the MAC installation, I think the simpler the better, can use on the line, after all, in the MAC is not possible as a server to use, as for boot start and do not start also does not matter, as long as the simple test can be done. The command line does not matter. There is a lot of time in the development of the connection to the company's server to do.

3, and for the installation under Linux, if the development of the server, then it is recommended to install the Deb version, that is, the form of the installation package, or the APT source for installation, installed after the automatic configuration of environment variables. The idea is to be able to use the line, do not need to be too complex configuration, more often at the time of development are connected to the company's server to do.

4, if for the server version of Linux, it is recommended to install the tar.gz compression package version, this installation is all manual configuration, including start-up services, environment variables, etc., because you can give you a very clear configuration of ideas, as to what is installed, what is configured, these can be one step to clear the troubleshooting. Of course, under the Linux deb or tar.gz each has its own benefits, after all, these can be selected according to the needs of the version.

5, by installing the tar.gz compression package version, that is, the binary package, can install multiple MySQL on the same machine.

Installation steps:

First, installation by Apt method

Description: This approach is fully referenced in the official tutorial https://dev.mysql.com/doc/mysql-apt-repo-quick-guide/en/.

Note: The version installed by APT is now the latest version, and now I am installing 5.7.18. After the installation is done this way, the boot-boot is already configured, and the environment variables on the command line are not manually configured.

1. (can omit) Download the official Mysql-apt-config.deb package for apt source settings: https://dev.mysql.com/downloads/repo/apt/

However, I feel that this configuration does not work, but can be configured to install what type of MySQL, and some common tools, etc., these can be manually through the Apt-get way to install the solution.

sudo dpkg-i mysql-apt-config_0.8.6-1_all.deb

After running, the following interface will appear:

Generally only need to default, press the arrow key to select OK enter.

When you are finished, run the update command:

sudo apt-get update

Description: After the official said to do this with this tool, the installation of MySQL is done according to the selection above.

2. Installation

sudo apt-get install Mysql-server

At this point, if you are prompted with insufficient dependencies, as follows:

Then you need to run the following command to resolve the dependency problem

sudo apt-get install-f

When you install MySQL, you will install the software shown below:

When finished, run the sudo apt-get install mysql-server again. If there is no dependency problem, you do not need to use this command.

3, the operation of the installation process:

The installation process prompts you for the login name and password for the database, as follows:

4, after the installation of the operation:

Note: After installation in this manner, the power-on boot has been configured, and the environment variables on the command line are not manually configured.

After installation, the following directory is created:

Database directory:/var/lib/mysql/

Configuration file:/usr/share/mysql (Command and configuration file),/etc/mysql (e.g. my.cnf)

Related commands:/usr/bin (mysqladmin mysqldump and other commands) and/usr/sbin

Startup script:/etc/init.d/mysql (startup script file mysql directory)

Test:

#服务启动后端口查询sudo NETSTAT-ANP | grep MySQL
#服务管理 # start sudo service mysql start# stop sudo service MySQL stop# service status sudo services MySQL status
#连接数据库mysql-H 127.0.0.1-p 3306-uroot-p123456#-h is the port number for the remote ip,-p,-U is the user name,-p is the password
#测试SQLshow databases;

Test everything is OK.

5. Uninstall

#首先使用以下命令删除MySQL服务器: sudo apt-get remove mysql-server# Then, remove any additional software that is automatically installed with the MySQL server: sudo apt-get autoremove# uninstalling other components: sudo Apt-get Remove <<package-name>> #查看从MySQL the list of installed packages for apt repositories: dpkg-l | grep MySQL | grep II

Second, install by downloading the offline install package Deb bundle

Note: Refer to the official installation documentation, reference: https://dev.mysql.com/doc/refman/5.7/en/linux-installation-debian.html

1. Download:

In fact, the Deb bundle type is the offline Deb installer package, which packs all the software.

Login site: https://dev.mysql.com/downloads/mysql/

Select System:

Select version, at the bottom select 16.04:

There will be Deb package on the list, this is actually the Deb file, but also the form of online installation, so the file is very small, not recommended choice.

2. Decompression

Tar xvf Mysql-server_5.7.18-1ubuntu16.04_amd64.deb-bundle.tar

The extracted files are as follows:

3. Installation

Description: The following command is available on the website

#libaio If the library does not already exist in the system, you may need to install the library: sudo apt-get install libaio1# use the following command to preconfigure the MySQL server package: sudo dpkg-preconfigure mysql-community-server_*.deb# tip: You will be asked to provide your MySQL installation password for the root user. #对于MySQL服务器的基本安装, install the database common package, client package, client-side meta-Package, server package, and server meta-package (in this order); You can do this with a single command: #注意: The following command cannot be run directly and should be disassembled in a comma-separated sequence of brackets, for example: #sudo dpkg-i mysql-{common,community-client,client, Community-server,server}_*.debsudo dpkg-i mysql-common_*.debsudo dpkg-i mysql-community-client_*.debsudo dpkg-i Mysql-client_*.debsudo dpkg-i Mysql-community-server_*.debsudo dpkg-i mysql-server_*.deb# If the dpkg warns of unsatisfied dependencies, You can use Apt-get to fix them before you run the interrupted command: sudo apt-get-f install

After the installation is complete and the first way effect is consistent.

Third, the installation through the tar.gz compression package

The following tutorials are available on the website, reference: https://dev.mysql.com/doc/refman/5.7/en/binary-installation.html

Note: This approach requires post-processing, such as boot-up service, command-line environment variables, and configuration file settings.

1. Download:

Site: https://dev.mysql.com/downloads/mysql/

2. Decompression

Tar zxvf mysql-5.7.18-linux-glibc2.5-x86_64.tar.gzsudo mv Mysql-5.7.18-linux-glibc2.5-x86_64/usr/localsudo ln-s/usr /local/mysql-5.7.18-linux-glibc2.5-x86_64//usr/local/mysql

3. Installation

Because the MySQL runtime requires the Libaio1 library, you need to run the following command to install it:

sudo apt-get install Libaio1
#添加用户组sudo groupadd mysql# Add user, this user is unable to log in sudo useradd-r-G mysql-s/bin/false mysql# into the file directory, MySQL is the link cd/usr/local/mysql #新建文件夹sudo mkdir mysql-files# Modify folder permissions sudo chmod mysql-filessudo chown-r mysql. sudo chgrp-r mysql. #安装初始化, note: The last line of this department There is an initial password for the first login for the root account sudo bin/mysqld--initialize--user=mysql #生成证书sudo bin/mysql_ssl_rsa_setup        #把权限修改回来      sudo chown-r root. sudo chown-r mysql data mysql-files

4. Start

#启动在后台sudo Bin/mysqld_safe--user=mysql &

5. Login test and change root password

/usr/local/mysql/bin/mysql-uroot-p

Hint: The last line of the password at the time of installation initialization, with parentheses and special characters.

#修改root密码, each semicolon directly returns mysql> SET PASSWORD = PASSWORD (' new password ');mysql> ALTER USER ' root ' @ ' localhost ' PASSWORD EXPIRE never;mysql> flush Privileges;
#增加一个 ' root ' @ '% ' account realization Telnet mysql> grant all privileges on * * to ' root ' @ '% ' identified by ' new password ' with GRANT option;

6. Configure the service to start automatically

#复制服务文件到/etc/init.dsudo Cp/usr/local/mysql/support-files/mysql.server/etc/init.d/mysql.server

Installing sysv-rc-conf

sudo apt-get install sysv-rc-conf

Start sysv-rc-conf

sudo sysv-rc-conf

Press the SPACEBAR to appear x, and then press Q to exit. Reboot.

Related Operations Command for the service:

#服务状态sudo Service mysql.server status# service starts sudo service mysql.server start# service stop sudo service mysql.server stop

7. Configure Environment variables

At the bottom of the ~/.profile file, add

Export path= $PATH:/usr/local/mysql/bin

Reference:

Http://www.cnblogs.com/oldfish/p/5039772.html (Deb Package-based installation)

http://blog.csdn.net/lllliulin/article/details/51526569 (Installation based on apt source)

Http://www.2cto.com/database/201401/273423.html (Installation based on apt source)

https://my.oschina.net/ramboo/blog/725378 (Install multiple MySQL based on binary package)

http://blog.csdn.net/carry9148/article/details/52624990 (binary package-based installation with Shell scripts for quick installation)

HTTP://WWW.JIANSHU.COM/P/B600C3B28BD9 (based on binary package installation)

Http://www.jianshu.com/p/90b5a749b3b0 (MY.CNF)

Http://www.fx114.net/qa-220-164752.aspx (MY.CNF)

Ubuntu 16.04 install MySQL (5.7.18)

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.