mysql5.7 installation practice process and troubleshooting reference

Source: Internet
Author: User
Tags mysql version uuid

learn about lamp and install MySQL services

Lamp=linux+apache+mysql+php a system of four components
Apache and PHP must be available on a single server, and MySQL can be used on a network basis to provide services
Apache cannot store data directly to MySQL, it must be stored in a database through the parsing module of PHP modules

Installing the MySQL servicePrevious operations for installing MySQL

Create a MySQL run user and group
Groupadd MySQL
Useradd-m-s/sbin/nologin-g MySQL MySQL

Download the MySQL compilation package on the official website or the mirror site

Install the environment that runs the compilation first before installing
Yum install gcc cpp glibc glibc-devel gcc-c++ ncurses-devel
Download the CMake compilation package for compilation and installation, the attachment is 3.12.0 version; Website address: www.cmake.org
./configure;make;make install CMake compile, all installation paths by default

Compile MySQL error boost does not exist

After MySQL version 5.7, you need to install a boost package and put the package in the compiled directory/usr/local/boost/

CMake Error at cmake/boost.cmake:81 (MESSAGE):  You can download it with -DDOWNLOAD_BOOST=1 -DWITH_BOOST=<directory>  This CMake script will look for boost in <directory>.  If it is not there,  it will download and unpack it (in that directory) for you.  If you are inside a firewall, you may need to use an http proxy:  export http_proxy=http://example.com:80Call Stack (most recent call first):  cmake/boost.cmake:238 (COULD_NOT_FIND_BOOST)  CMakeLists.txt:455 (INCLUDE)-- Configuring incomplete, errors occurred!
The error message is probably as above; error message solution

First to the official website to download is boost_1_64_0.tar.gz, and then put the compressed package into the/usr/local/boost directory, again CMake but error continues. After Baidu after a few, said no need to decompress only need to put the compressed package in the specified directory can be
Put boost_1_64_0.tar.gz in the directory, once again CMake found that the recognition is not, he will download another version, the results of the download timeout.
Then the boost website downloads the required version boost_1_59_0.tar.gz

Boost's website history version: http://www.boost.org/users/history/

Then put the downloaded tar package in the/usr/local/boost directory and continue CMake.

Compile parameter reference and compile results for MySQL:

  [[email protected] mysql-5.7.22]# cmake.-dcmale_install_prefix=/usr/local/mysql-dmysql_datadir=/ Var/mysql/data-dsysconfdir=/etc-dwith_myisam_storage_engine=1-dwith_innobase_storage_engine=1-dwith_archive_ Storage_engine=1-dmysql_unix_addr=/usr/local/mysql/mysql.sock-dwith_partition_storage_engine=1-dextra_charsets =all-ddefault_charset=utf8-ddefault_collation=utf8_general_ci-dwith-systemd=1-dwith_boost=/usr/local/ Boost-----------------------ellipsis process------------------------cmake_c_link_flags:--cmake_cxx_link_flags:--CMAKE_C_ Flags_relwithdebinfo:-o3-g-fabi-version=2-fno-omit-frame-pointer-fno-strict-aliasing-ddbug_off--CMAKE_CXX_ Flags_relwithdebinfo:-o3-g-fabi-version=2-fno-omit-frame-pointer-fno-strict-aliasing-ddbug_off--Configuring done--generating done--Build files with been written to:/usr/local/src/mysql-5.7.22[[email protected] mysql-5.7.22]# Echo $?0  

If the result is the same as I do not error, continue to make compile, if there is an error, please read the wrong message, most of them are not installed some software packages caused by, please paste the error information into the search engine query

[[email protected] mysql-5.7.22]# makeScanning dependencies of target abi_check[ 0%] Built target abi_checkScanning dependencies of target INFO_SRC[ 0%] Built target INFO_SRCScanning dependencies of target INFO_BIN[ 0%] Built target INFO_BINScanning dependencies of target zlib----------------省略过程------------------------[ 99%] Building C object libmysqld/examples/CMakeFiles/mysql_client_test_embedded.dir/__/__/testclients/mysql_client_test.c.o[ 99%] Linking CXX executable mysql_client_test_embedded[ 99%] Built target mysql_client_test_embeddedScanning dependencies of target my_safe_process[100%] Building CXX object mysql-test/lib/My/SafeProcess/CMakeFiles/my_safe_process.dir/safe_process.cc.o[100%] Linking CXX executable my_safe_process[100%] Built target my_safe_process[[email protected] mysql-5.7.22]# aecho $?0

Installation without error, complete final install make install, compile result is successful

-----------------------过程省略----------------------- Installing: /usr/local/mysql/support-files/mysqld_multi.server-- Installing: /usr/local/mysql/support-files/mysql-log-rotate-- Installing: /usr/local/mysql/support-files/magic-- Installing: /usr/local/mysql/share/aclocal/mysql.m4-- Installing: /usr/local/mysql/support-files/mysql.server[[email protected] mysql-5.7.22]# echo $?0
The basic installation is complete and the next step is to configure MySQL startup and configuration items

recursion specifies the permissions of the user and the group to which MySQL belongs

[[email protected] ]# chown -R mysql:mysql /usr/local/mysql/
Initialization of the database

The compiled database is initialized, where the MySQL initialization information contains a randomly generated password

  [[email protected] mysql-5.7.22]#/usr/local/mysql/bin/mysqld--initialize--user=mysql--basedir=/ Usr/local/mysql--datadir=/usr/local/mysql/data2018-07-28t09:08:42.088874z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. --explicit_defaults_for_timestamp server option (see documentation for more details). 2018-07-28t09:0 8:42.590615z 0 [Warning] innodb:new log files created, lsn=457902018-07-28t09:08:42.861362z 0 [Warning] innodb:creating  FOREIGN KEY constraint system tables.2018-07-28t09:08:42.955937z 0 [Warning] No existing UUID have been found, so we assume That's the first time that this server has been started. Generating a new uuid:d342a57c-9245-11e8-bf5e-080027a7f9c2.2018-07-28t09:08:42.965634z 0 [Warning] Gtid table is not rea Dy to be used. Table ' mysql.gtid_executed ' cannot be opened.2018-07-28t09:08:42.966858z 1 [Note] A temporary password are generated for [E Mail protected]: thuqg=%m!12j--This is the initial generated password  
MY.CNF and/etc/init.d/mysqld files

Copy the service startup file and modify the MY.CNF configuration file. Specify MySQL installation path and path to store data and add system services

[[email protected] ]# cp /usr/local/src/mysql-5.7.22/support-files/mysql.server /etc/init.d/mysqld[[email protected] ]# vim /etc/init.d/mysqld [[email protected] ]# chmod +x /etc/init.d/mysqld [[email protected] ]# ls -l /etc/init.d/mysqld -rwxr-xr-x 1 root root 10609 7月 28 17:21 /etc/init.d/mysqld[[email protected] ]# chkconfig --add mysqld[[email protected] ]# chkconfig --list 注意:该输出结果只显示 SysV 服务,并不包含原生 systemd 服务。SysV 配置数据可能被原生 systemd 配置覆盖。       如果您想列出 systemd 服务,请执行 ‘systemctl list-unit-files‘。      欲查看对特定 target 启用的服务请执行      ‘systemctl list-dependencies [target]‘。mysqld 0:关  1:关 2:开 3:开 4:开 5:开 6:关netconsole 0:关  1:关 2:关 3:关 4:关 5:关 6:关network 0:关 1:关 2:开 3:开 4:开 5:开 6:关

Edit the MySQL configuration file for my.cnf

[[email protected] ]# less /etc/my.cnf[mysqld]basedir = /usr/local/mysql/  datadir = /usr/local/mysql/data  port = 3306  character-set-server = utf8  explicit_defaults_for_timestamp = true  # socket = /var/run/mysqld/mysqld.sock # Disabling symbolic-links is recommended to prevent assorted security riskssymbolic-links=0# Settings user and group are ignored when systemd is used.# If you need to run mysqld under a different user or group,# customize your systemd unit file for mariadb according to the# instructions in http://fedoraproject.org/wiki/Systemd[mysqld_safe]log-error=/var/log/mariadb/mariadb.logpid-file=/var/run/mariadb/mariadb.pid## include all files from the config directory#!includedir /etc/my.cnf.d
MySQL Start-up process

After adding complete following system startup, start the MySQL service:

[[email protected] ]# /etc/init.d/mysqld startStarting MySQL.2018-07-28T09:23:23.822700Z mysqld_safe error: log-error set to ‘/var/log/mariadb/mariadb.log‘, however file don‘t exists. Create writable for user ‘mysql‘. ERROR! The server quit without updating PID file (/usr/local/mysql/data/localhost.pid).

Create a MySQL log file according to the error message, and then try to start

[[email protected] ]# mkdir -p /var/log/mariadb/mariadb[[email protected] ]# touch /var/log/mariadb/mariadb.log[[email protected] ]# chown -R mysql:mysql /var/log/mariadb/mariadb

Try to start the MySQL service again and start the success

[[email protected] support-files]# /etc/init.d/mysqld startStarting MySQL. SUCCESS! [[email protected] support-files]# ps -aux |grep mysqlroot 21812 0.0 0.1 113312 1636 pts/0 S 17:28 0:00 /bin/sh /usr/local/mysql//bin/mysqld_safe --datadir=/usr/local/mysq/data --pid-file=/usr/local/mysql/data/localhost.pidmysql 22000 1.7 16.3 1112372 166604 pts/0 Sl 17:28 0:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql//lib/plugin --user=mysql --log-error=/var/log/mariadb/mariadb.log --pid-file=/usr/local/mysql/data/localhost.pid --port=3306root 22030 0.0 0.0 112724 976 pts/0 R+ 17:28 0:00 grep --color=auto mysql
Log in to MySQL and modify the default generated password

MySQL generated a random high-intensity password at the time of initialization, this password is not our own set, the next is to change the default password to a compliant password, here to change the password for [email protected]
Unlike mysql5.7 and 5.5 and 5.6, a random password is carried when the service is successfully started, and the default password must be modified in other ways to facilitate later use

[[email protected] ~]# /usr/local/mysql/bin/mysqladmin -u root -h localhost passwrod ‘NOWpassword‘ -pEnter password: mysqladmin: connect to server at ‘localhost‘ failederror: ‘Your password has expired. To log in you must change it using a client that supports expired passwords.‘

This change password prompt password expires, you need to make a password modification on a client

Here's how to modify the MySQL password:

[[email protected] ~]# mysql -u root -pEnter password: Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 7Server version: 5.7.22Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.mysql> alter user ‘root‘@‘localhost‘ identified by ‘[email protected]‘;Query OK, 0 rows affected (0.00 sec)mysql> flush privileges;Query OK, 0 rows affected (0.00 sec)
Official explanation of the default password for mysql5.7

In order to improve the security mysql5.7 the user table in the password field has been canceled, instead of the Authentication_string field, of course, we change the password can not be modified with the original users table to achieve
The method of mysql5.7 password modification on the network is suitable for mysql5.7

方法一:mysql> alter user ‘root‘@‘localhost‘ identified by ‘[email protected]‘;方法二:mysql> set password for ‘root‘@‘localhost‘=password(‘[email protected]‘);修改完成后刷新数据库表内容mysql> flush privileges;
MySQL starts the service without a boot file
[[email protected] mysql]# /usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my,cnf --user=mysql --detadir=/usr/local/mysql/data/mysql &[1] 22873[[email protected] mysql]# Logging to ‘/usr/local/mysql/data/localhost.err‘.2018-07-28T10:06:55.233375Z mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data2018-07-28T10:06:55.242274Z mysqld_safe mysqld from pid file /usr/local/mysql/data/localhost.pid ended[1]+ 完成 /usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my,cnf --user=mysql --detadir=/usr/local/mysql/data/mysql[[email protected] mysql]# ps -aux |grep mysql

mysql5.7 installation practice process and troubleshooting reference

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.