MySQL Basic Environment _ Installation Configuration tutorial (Windows7 64 or Centos7.2 64, MySQL5.7)

Source: Internet
Author: User
Tags flush session id mysql in mysql version yum repolist

MySQL Basic Environment Installation Configuration tutorial (Windows7 64 or Centos7.2 64, MySQL5.7)

    1. Install package version

1) vmawre-workstation version Package

Address:

https://my.vmware.com/web/vmware/details?downloadGroup=WKST-1411-WIN&productId=686&rPId=20814

Package Name: Vmware-workstation-full-12.5.7.20721.exe

2) Windows version Package

Address: Https://www.microsoft.com/zh-cn/software-download/windows7

Package Name:

3) CentOS Version Package

Address: http://vault.centos.org/7.2.1511/isos/x86_64/

Package Name: Centos-7-x86_64-dvd-1511.iso

4) JDK version package

Address: http://www.oracle.com/technetwork/java/javase/downloads/index.html

Package Name: jdk-8u144-linux-x64.tar.gz

5) MySQL version pack

Windows edition

Address: https://www.mysql.com/downloads/

Package Name: Mysql-5.7.20-winx64.zip

Linux Edition

Address: https://repo.mysql.com//mysql57-community-release-el7-11.noarch.rpm

Package Name: mysql57-community-release-el7-11.noarch.rpm

    1. Install packages

2.1. Pre-installation Instructions

Prepare the package files you need to install, such as Linux, JDK, MySQL database installation package, etc., download the package you need to build the environment and upload it to the corresponding Linux machine. Package files are uniformly placed under directory/usr/local/src.

When downloading the corresponding package, first confirm the number of bits of the system, so that you can confirm the need to download a few bits of the package, such as: The system is 32-bit, install 32-bit package, the system is 64-bit, install 64-bit package. Installation of the basic environment refer to the following instructions, the corresponding IP, port number, path and so on according to the actual situation of your machine to modify. When the display is x86_64, it indicates a 64-bit system, otherwise 32-bit system.

Uname-a

2.2. Installing Vmwawre-workstation12

2.2.1. Installing Vmwawre-workstation12

Choose a good installation path, and the default installation will be done.

2.2.2. Installing a virtual machine

2.2.2.1. Creating a new virtual machine

Choose to install the corresponding VM workstation version

2.3. Installing CentOS7.2

2.3.1. Loading the CentOS ISO file

Edit the virtual machine, hardware (CD/DVD (IDE)), use the ISO image file, select the corresponding CentOS ISO package, select OK, save and start the virtual machine, and then go to install the CentOS interface.

2.3.2. Installing CentOS7.2

Select Install CentOS7.2 and select the Enter key

2.3.2.1. Selecting a language set

2.3.2.2. Editing each module information

2.3.2.2.1. Editing the time module

2.3.2.2.2. Configuring the keyboard module

2.3.2.2.3. Other item configurations (auto-partitioning, disabling Kdump)

2.3.2.2.4. Modifying the root user password

2.3.2.2.5. Enable NIC (Ifup command)

Because the installation is CentOS6, so there will not find repo problems, and finally found to open the network card.

2.3.2.3. Restarting CentOS7

Shutdown-r now

After installing the system, reboot the system, and after logging in, execute the Yum List command.

2.3.3. Making basic settings

2.3.3.1. Starting the network card

Cd/etc/sysconfig/network-scripts

Ifup ifcfg-ens160

Yum-y Install net-tools.x86_64

2.3.3.2. Installing wget

Rpm-qa|grep wget If no content is displayed, the wget command is not installed

Yum-y Install wget

2.3.3.3. Replacing a Yum source

cd/etc/yum.repos.d/

CP Centos-base.repo Centos-base.repo.backup

#下载CentOS7的yum Source

wget Http://mirrors.163.com/.help/CentOS7-Base-163.repo

#将163yum源替换原来的yum源

Mv-f Centos7-base-163.repo Centos-base.repo

#生成yum缓存并完成yum源的替换

Yum Clean All

Yum Makecache

2.3.3.4. Installing VIM

Yum-y Install Vim

2.3.3.5. Shutting down the firewall

#关闭防火墙 if enabled, it needs to be closed.

/usr/sbin/sestatus-v

#关闭selinux

Vim/etc/selinux/config

Selinux=disabled

#禁用系统防火墙

Systemctl Disable FIREWALLD

Systemctl Stop Firewalld

Systemctl Status Firewalld

2.3.3.6. Installing additional commands

Install htop dstat nload bmon telnet Dos2unix

#安装epel

RPM-IVH epel-release-7-9.noarch.rpm

#安装htop Dstat nload Bmon

Yum-y Install htop dstat nload Bmon Dos2unix

2.4. Installing JDK1.8

2.4.1. Installing JDK1.8

cd/usr/local/src/

TAR-ZXVF jdk-8u144-linux-x64.tar.gz-c/usr/local/

cd/usr/local/

#更改jdk文件名称

MV jdk1.8.0_144 jdk1.8

#更改所属的用户和组

Chown-r Root:root jdk1.8

2.4.2. Configuring Java Environment variables

Vim/etc/profile or modify the. bash_profile file

#新增以下配置想到 the/etc/profile file

#JDK1.8

Java_home=/data/local/java

Path= $PATH: $HOME/bin: $JAVA _home/bin

Classpath=.: $JAVA _home/lib: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar

#LD_LIBRARY_PATH =/opt/apr1.5/lib

Export Java_home PATH CLASSPATH Ld_library_path

#优化tomcat8需要配置该项

#export Ld_library_path=/opt/apr1.5/lib

#让配置文件生效 Source/etc/profile

2.4.3. Modifying the Java.security file

#启动tomcat出现下列问题的解决办法

Info:creation of SecureRandom instance for session ID generation using [Sha1prng] took [24,790] milliseconds.

Open the $jre_home/lib/security/java.security file and find the following:

Securerandom.source=file:/dev/random

Replaced by

Securerandom.source=file:/dev/./random

#通过javac-version and java-version command to check if the JDK installation was successful

2.5. Installing MySQL5.7

2.5.1. Installing MySQL5.7 in Windows7

2.5.1.1. Accessing the download page

Address: https://www.mysql.com/downloads/

Package Name: Mysql-5.7.20-winx64.zip

2.5.1.2. Select the corresponding version

Because my server is windows, download the MySQL version that supports the Windows environment

2.5.1.3. Go to the download page

Click on the Download button to go to the download page

2.5.1.4. Installing and configuring MySQL

#解压缩安装包文件到具体目录

Path is: D:\MySQL5.7

To configure environment variables:

mysql_home=d:\mysql5.7;

Path=%mysql_home%\bin;

#进入mysql的bin目录, open the Doc window as an administrator and run the command to install MySQL

#安装mysql

The My.ini file is configured as follows:

2.5.1.5. Initializing MySQL

Mysqld--initialize-insecure

#卸载服务

Mysqld-remove

2.5.1.6. Performing the install MySQL command

Mysqld-install MySQL--defaults-file= "D:\MySQL5.7\my.ini"

2.5.1.7. Starting and stopping MySQL

net start MSYQL

net stop MySQL

2.5.1.8. Setting the MySQL user password

#首次访问mysql without direct access to the password

Mysql-u root-p

Direct return

#修改root用户密码

Set password for [email protected]=password (' 123456 ');

Flush privileges;

Exit

2.5.1.9. Troubleshoot root user's inability to access MySQL

#访问mysql, if the following error occurs, you need to modify the configuration file My.ini

Add Skip-grant-tables under [Mysqld], and then restart the MySQL service

#重启mysql服务后登陆mysql数据库

net stop MySQL

net start MySQL

Mysql-u root-p

Enter the password after the carriage return: 123456

show databases;

2.5.2. Installing MySQL5.7 in CentOS7

2.5.2.1. Database directory Structure description

Configuration file Path/etc/my.cnf

Log file path/var/log/mysqld.log

MySQL startup script/usr/lib/systemd/system/mysqld.service

Socket file Path/var/lib/mysql/mysql.sock

PID File path/var/run/mysqld/mysqld.pid

2.5.2.2. Uninstalling MARIADB

Rpm-qa |grep Maria

Yum Remove maraidb-libs-y

2.5.2.3. Visit MySQL official website

: https://dev.mysql.com/downloads/file/?id=470281

Package Name: mysql57-community-release-el7-11.noarch.rpm

2.5.2.4. Download the installation package to Linux

Go to file storage path

Cd/usr/local/src

wget https://repo.mysql.com//mysql57-community-release-el7-11.noarch.rpm

2.5.2.5. Download the Yum source that supports the RPM installation of MySQL

Yum Localinstall mysql57-community-release-el7-11.noarch.rpm

2.5.2.6. Checking the yum source for MySQL

Check if the MySQL yum repo source is available

Yum repolist enabled |grep "Mysql.*-community.*"

2.5.2.7. Installing MySQL in yum mode

Install MySQL

Yum-y Install Mysql-commuinty-server

If prompted, the installation of MySQL is successful.

2.5.2.8. Starting the MySQL service

Start the MySQL service

Systemctl Start mysqld

2.5.2.9. Setting up Boot

Set boot auto-start

Systemctl Enable Mysqld

Systemctl Daemon-reload

2.5.2.10. Setting the root password for MySQL

Get the root user temporary password to log in to MySQL

grep ' temporary password '/var/log/mysqld.log

Access MySQL with a temporary password

Alter user ' root ' @ ' localhost ' identified by ' [email protected]/# ';

[Email protected] opt]# mysql-uroot-p

Enter Password: temporary password

mysql> alter user ' root ' @ ' localhost ' identified by ' [email protected]/# ';

Change Password Policy

Mysql> Show variables like '%password ';

Set global validate_password_policy=0;

Set global validate_password_length=4;

Reset Password again

mysql> alter user ' root ' @ ' localhost ' identified by ' 123456 ';

1 new test users with remote access to MySQL

Mysql> Grant all privileges on * * to ' test ' @ ' percent ' identified by ' 123456 ' with GRANT option;

2.5.2.11. Configuring a MySQL-supported character set

In the [mysqld] configuration item, add support for UTF-8 encoding

Vim/etc/my.cnf

Character-set-server=utf8mb4

Collation-server=utf8mb4_unicode_ci

init_connect= ' SET NAMES utf8mb4 '

Restart MySQL

Systemctl Restart Mysqld

The following error occurred after logging in:

ERROR 1045 (28000): Access denied for user ' root ' @ ' localhost ' (using Password:yes)

2.5.2.12. Reset the root password for MySQL (when the 8th step is unsuccessful)

The/ETC/MY.CNF [MSYQLD] Item is added skip-grant-tables

Restart MySQL

Systemctl Restart Mysqld

#mysql-uroot-p

Enter Password: original password

Mysql>use MySQL;

Mysql>update User Set Authentication_string=password ("123456") where user= "root";

Mysql>flush privileges;

mysql>exit;

The skip-grant-tables annotation in the/ETC/MY.CNF [MSYQLD] Item is then

and restart MySQL.

Systemctl Restart Mysqld

If the problem occurs

Failed:access denied for user ' root ' @ ' 192.168.0.129 ' (using Password:yes) in./mysqlreport Line 249

You can start with the configuration file

In/ETC/MY.CNF

[Client]

Host=localhost

User=xxx

Password=xxx

After restarting the database

When you execute the statement

Mysql>insert into ' user ' VALUES ('% ', ' root ', ' y ', ' y ', ' y ', ' y ', ' y ', ' y ', ' y ', ' y ', ' y ', ' y ', ' y ', ' y ', ' y ', ' y ', ' y ', ' y ', ' y ' , ' y ', ' y ', ' y ', ' y ', ' y ', ' y ', ' y ', ' y ', ' y ', ' y ', ' y ', ' y ', ', ', ', ', ', 0,0,0,0, ' Mysql_native_password ', ' * 6bb4837eb74329105ee4568dda7dc67ed2ca2ad9 ', ' n ', localtime (), NULL, ' n ');

Mysql>flush privileges;

Then comment The following configuration items

In/ETC/MY.CNF

[Client]

Host=localhost

User=xxx

Password=xxx

2.5.2.13. Troubleshooting Remote Tools cannot connect to MySQL server

In the Remote Linux window, log in to MySQL using the root user

Mysql-uroot-p

Switch to MySQL database

Execute the statement and update the operation

Update user set host= '% ' where user= ' root ';

Flush privileges;

MySQL Basic Environment Installation Configuration tutorial (Windows7 64 or Centos7.2 64, MySQL5.7)

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.