Install mysql5.7 under Linux

Source: Internet
Author: User
Tags iptables

Tag: init indicates data grep about unable to chkconfig SQL file name

A website Download mysql-5.7.12-linux-glibc2.5-x86_64.tar.gz

Currently 5.7.16, can download mysql-5.7.16-linux-glibc2.5-x86_64.tar.gz directly,

Here is the 5.7.12, not download the latest, however, the same installation method.

Website address: http://www.mysql.com/downloads/

After clicking on MySQL Community server, go to the following page:

Select the corresponding number version click Download, the current official website has been updated to 5.7.16, you can download the latest version of the installation, 5.7 installation method is the same:

Go to the download page and click to download:

After downloading through the xftp and other ways to upload to the Linux system habits directory.

Two install MySQL

(1) Uninstalling mysql******

If MySQL is not installed on the system, this step does not require

1. Turn off the MySQL service

2. Check if there is a RPM package, if not with RPM installed MySQL, there should be no residue, if any, need to remove

Check syntax: rpm-qa|grep-i mysql

Delete Syntax: RPM-E < package name >

If you encounter dependencies that cannot be deleted, use RPM-E--nodeps < package name > do not check dependencies and delete rpm packages directly.

3. Check if there is a MySQL file installed through the Find command, you need to delete

Check syntax: Find/-name MySQL

Delete syntax: Rm-rf directory file (or file)

In addition to their own download or decompression, the rest of the kill.

(2) Create MySQL group and user ******

1. Violent removal of MySQL users

Delete syntax: Userdel-r-F MySQL (if not, will prompt you that MySQL does not exist, do not care)


2. Add a group

Add syntax: Groupadd mysql

3. Add MySQL User

Add syntax: useradd-g mysql MySQL

4. Set a password for the MySQL user

passwd MySQL

:

About: Userdel:warning:can ' t remove/var/spool/mail/mysql:no such file or directory

Because there is no/var/spool/mail/mysql, so warning, through find/-name MySQL did not check it,

Instead of prompting, create a group and add MySQL users directly down the block.

This should not happen if MySQL is not installed on the system.

(3) Unzip the TAR package ******

1. CD to mysql-5.7.12-linux-glibc2.5-x86_64.tar.gz directory

2. Unzip the TAR package

Decompression syntax: Tar zxvf mysql-5.7.12-linux-glibc2.5-x86_64.tar.gz

Extract more than one mysql-5.7.12-linux-glibc2.5-x86_64 file,

Copy this file to your favorite directory, rename it to MySQL, and please be patient while copying.

After copying the CD to the MySQL directory, create a new data folder.

Copy syntax: Cp-r mysql-5.7.12-linux-glibc2.5-x86_64/usr/local/mysql

New file Syntax: mkdir data

:

(4) Installation execution ******

1. CD to/usr/local/mysql directory, if already in MySQL directory, no need to change

Check your current directory with PWD to see if the MySQL directory

2. CD to/usr/local/mysql/bin directory, execute the following command

./mysql_install_db--user=mysql--basedir=/usr/local/mysql/--datadir=/usr/local/mysql/data/

Enter to execute

Execution Result:

3. As you can see from the warning, mysql_install_db is no longer in use, we recommend that we install it using MYSQLD and execute the following command

./mysqld--user=mysql--basedir=/usr/local/mysql/--datadir=/usr/local/mysql/data/

Enter to execute

:

After the carriage return, see Print a lot of information, look very hopeful, patient wait.

Of course, if you see the last print to:

Version: ' 5.7.12 ' socket: '/tmp/mysql.sock ' port:3306 mysql Community Server (GPL)

:

If you see this sentence, if you are using a shell, copy a terminal window and proceed to the following operation in a new window.

Copy method:

(5) test if MySQL can start ******

1. CD to/usr/local/mysql/support-files/

Edit Mysql.server, the syntax is: Vim mysql.server

:

2. Modifying the Basedir and DataDir paths

Basedir=/usr/local/mysql

Datadir=/usr/local/mysql/data

:

3. Save and exit, if you cannot save the exit using the x command, you can use wq! to save and force exit

Save and exit steps:

Press the ESC key in the upper-left corner of the keyboard first,

Then hold down the SHIFT key and enter: number

Last input wq!

Enter Save and exit

:

4. Start the test

./mysql.server Start

:

If you see starting MySQL success!, we have successfully installed MySQL because we started it successfully,

If you are successful in this step, continue to reference it, or you need to check carefully what is wrong.

Note: Installation is for reference only, if there is a problem, please be more tolerant, everyone's system or environment is different.

(6) Creating a soft connection ******

Ln-s/usr/local/mysql/bin/mysql/usr/bin

:

What is the use of soft connections, plainly, is to add MySQL to the Linux system command, Linux system commands placed under the/usr/bin,

As with the C:\Windows\System32 directory in Windows, commands on Windows are in Xxx.exe form,

For example Telnet.exe, if there is no such file, the Windows Command window will be prompted to use the command telnet command does not exist,

This is the place to operate, in order to use the MySQL command later, can have this command to pave the way.

(7) Create MySQL configuration file ******

1. MY.CNF Configuration

First, if/etc/my.cnf exists, delete the my.cnf directly.

Then, MV/USR/LOCAL/MYSQL/SUPPORT-FILES/MY-DEFAULT.CNF/ETC/MY.CNF

Editor, VIM/ETC/MY.CNF

:

In my.cnf, locate [mysqld], where the following configuration is added:

Basedir=/usr/local/mysql

Datadir=/usr/local/mysql/data

Character_set_server=utf8

[Client]

Default-character-set=utf8

Also delete or comment out the contents of the My.cnf file:

#sql_mode =no_engine_substitution,strict_trans_tables

:

Finally save and exit.

2. Mysqld Configuration

2.1. Copy the boot file to/etc/init.d/and command to Mysqld

Cp/usr/local/mysql/support-files/mysql.server/etc/init.d/mysqld

2.2. Increase execution privileges

chmod 755/etc/init.d/mysqld

2.3. Check the self-startup item list for no mysqld

Chkconfig--list mysqld

2.4. If not, add mysqld

Chkconfig--add mysqld

2.5. Set Boot up

Chkconfig mysqld on

2.6. Start the test

Service mysqld Start

:

Description of our configuration file succeeded, MySQL complete installation completed.

(8) Reset password ******

1. Modify the configuration file my.cnf

Vim/etc/my.cnf

2. Find [mysqld] after adding

Skip-grant-tables

Save exit

3. Restart the MySQL service
Service mysqld Restart

Restart:

4. Direct login to MySQL without password

Mysql-u root-p (Straight return)

After entering the effect:

5. Enter in MySQL

Update Mysql.user set Authentication_string=password (' 123456 ') where user= ' root ';

6. Refresh Permissions
Flush Privileges

:

7. Quit MySQL, and in my.cnf, comment out or delete the skip-grant-tables that you started adding


8. Restart the MySQL service

Service mysqld Restart

9. Login

Mysql-u root-p

Enter your password and you can.

:

After the completion of the above work, our MySQL is finished, but, want to let the outside world through the tool connection also need to be set.

(9) Tool connection 3306 Port database ******

1. Log in to MySQL

Mysql-u root-p

2. Modify the user table of the MySQL library to change the host entry from localhost to%.

% This means that any host access is allowed, and if only one IP access is allowed, the corresponding IP can be changed.

Note: The following commands suggest manual input to avoid unnecessary hassles.

3. Use MySQL;

4. SET PASSWORD = PASSWORD (' 123456 ');


5. Update user Set host = '% ' where user = ' root ';

6. Select host, user from user;

7. Flush privileges;

:

8. Firewall Open 3306 Port

Edit Iptables File:

Add 3306 ports to the file, save and exit, such as:

Restart Iptables:

Syntax: Service iptables restart

:

9. Let's try to connect with the tool

Enter your database service IP, database password, the password set above is 123456, depending on your settings.

OK, see the default effect:

Use the tool to manipulate the database arbitrarily.

To this, the MySQL installation is complete.

Install mysql5.7 under Linux

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.