Install MySQL database 5.6 source code under Linux and change the login user password

Install MySQL database 5.6 source code under Linux and change the login user password

This article mainly explains how to install the MYSQL database under Linux, and uses the installation of MYSQL5.6 version as an example to teach you how to modify the login username and password.

Source code download address http://dev.mysql.com/downloads/mysql/5.6.html#downloads

tar.gz address: https://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.37.tar.gz

Select Generic Linux (Architecture Independent), Compressed TAR Archive

Select No thanks, just start my download.

operating system:

centos6.5 x86_64

1. Yum installation related dependencies

# yum -y install gcc gcc-c++ gcc-g77 autoconf automake zlib* fiex* libxml* ncurses-devel libmcrypt* libtool-ltdl-devel* make cmake bison git openssl openssl-devel

2. Compile and install

1. Add users

groupadd mysql

useradd -r -g mysql mysql

2. Compile and install

tar xf mysql-5.6.34.tar.gz

cd mysql-5.6.34

#By default, it is installed in /usr/local/mysql

# cmake compilation parameters can be adjusted by yourself

************************************************************** 
-- Looking for asprintf 
-- Looking for asprintf - found 
-- Check size of pthread_t 
-- Check size of pthread_t - done 
-- Using cmake version 2.8.12.2 
-- Not building NDB 
--Performing Test HAVE_PEERCRED 
-- Performing Test HAVE_PEERCRED - Success 
-- Library mysqlclient depends on OSLIBS -lpthread;/usr/lib64/libz.so;m;rt;/usr/lib64/libssl.so;/usr/lib64/libcrypto.so;dl 
-- Googlemock was not found. gtest-based unit tests will be disabled. You can run cmake . -DENABLE_DOWNLOADS=1 to automatically download and build required components from source. 
-- If you are inside a firewall, you may need to use an http proxy: export http_proxy=http://example.com:80 
-- Library mysqlserver depends on OSLIBS -lpthread;/usr/lib64/libz.so;m;rt;/usr/lib64/libssl.so;/usr/lib64/libcrypto.so;dl;crypt 
--CMAKE_BUILD_TYPE: RelWithDebInfo 
-- COMPILE_DEFINITIONS: HAVE_CONFIG_H 
-- CMAKE_C_FLAGS: -Wall -Wextra -Wformat-security -Wvla -Wwrite-strings -Wdeclaration-after-statement 
-- CMAKE_CXX_FLAGS: -Wall -Wextra -Wformat-security -Wvla -Woverloaded-virtual -Wno-unused-parameter 
-- 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 
CMake Warning: 
 Manually-specified variables were not used by the project: 
  WITH_READLINE 
-- Build files have been written to: /root/mysql-5.6.34

**************************************************************
Cmake compilation error requires deleting the compilation cache, fixing the error and recompiling again

rm -f CMakeCache.txt

3.make && make install

Note:

When recompiling, old object files and cached information need to be cleared.

# make clean

# rm -f CMakeCache.txt

# rm -rf /etc/my.cnf

4. Change the data storage directory owner to mysql

chown -R mysql.mysql /usr/local/mysql

chown -R mysql.mysql /data/mydata

5. Start the script to initialize the database

cd /usr/local/mysql

# scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/data/mydata

6. Registration Service

cp support-files/mysql.server /etc/rc.d/init.d/mysqld

#Use the default configuration file

cp support-files/my-default.cnf /etc/my.cnf

#Let chkconfig manage mysql service

chkconfig --add mysqld

#Startup

chkconfig mysqld on

Edit vi /etc/my.cnf configuration and add the following content

innodb_file_per_table = 1

datadir = /data/mydata

log-bin=/data/binlogs/mysql-bin

Notice:

After actual testing, the parameter innodb_file_per_table = ON requires innodb_file_per_table = 1 to take effect.

mysql> show variables like '%per_table%'; to query

mkdir /data/binlogs

chown -R mysql.mysql /data/binlogs

8. Add the mysql command to the environment variable

vim /etc/profile.d/mysql.sh

join in

export PATH=/usr/local/mysql/bin:$PATH

The default password is empty

9 Modify vi /etc/security/limits.conf, then add the following content, log out and log in again (no need to restart, just exit the current connection shell)

# ulimit -n Check whether the parameter is effective

* hard nofile 655350

*soft nofile 655350

Otherwise, the error is as follows:

Error #23: Out of resources when opening file './XX/USER.MYD' (Errcode: 24)

at the same time

vim /etc/security/limits.d/90-nproc.conf

Delete the following line to remove centos's restrictions on file operation handles:

* soft nproc 1024

About starting and stopping mysql

/etc/init.d/mysqld start

/etc/init.d/mysqld stop

Check whether MySQL has been started successfully

ps -elf |grep mysql |grep -v grep

Change to allow IP access (enter mysql: 2. Use mysql library: 3. View user table: 4. Update user table: 5. Force refresh permissions:)

/usr/local/mysql/bin/mysql -u root -p

use mysql;

SELECT `Host`,`User` FROM user;

UPDATE user SET `Host` = '%' WHERE `User` = 'root' LIMIT 1;
flush privileges;

Change the password of the MySQL database login user. You can use the navcat client to connect and change the password of the login user.

#mysql -uroot -p

Enter password: [The default password for the original installation is left blank and the password is entered directly]

mysql>use mysql;

mysql> update user set password=passworD("root") where user='root';

mysql> flush privileges;

mysql> exit;

Before using the client connection test, be sure to open the connection port 3306 in the firewall

vi /etc/sysconfig/iptables

After port 22

-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT

Restart the firewall to take effect

service iptables restart

You may also be interested in:
  • A detailed introduction to the three installation methods of rpm, yum and source code under Linux
  • How to install MySQL under Linux (yum and source code compilation)
  • Tutorial on installing mysql5.6.20 from source code under linux
  • Compile and install PostgreSQL9.5 from source code on Linux CentOS 7
  • How to install mysql source package in Linux CentOS6.6 system
  • Notes on installing MySQL source code under Linux
  • Sharing the steps of compiling, installing and configuring SVN server under Linux
  • How to install MySQL 5.6 from source code under SUSE Linux
  • Linux+php+apache+oracle environment construction: source code compilation and installation of PHP under CentOS
  • Analysis of Linux kernel scheduler source code initialization

<<:  Talk about nextTick in Vue

>>:  Complete steps to build a squid proxy server in linux

Recommend

Example tutorial on using the sum function in MySQL

Introduction Today I will share the use of the su...

Getting Started with MySQL - Concepts

1. What is it? MySQL is the most popular relation...

Why is it not recommended to use index as the key attribute value in Vue?

Table of contents Preface The role of key The rol...

Linux five-step build kernel tree

Table of contents 0. The kernel tree that comes w...

Linux system to view CPU, machine model, memory and other information

During system maintenance, you may need to check ...

Detailed Example of CSS3 box-shadow Property

CSS3 -- Adding shadows (using box shadows) CSS3 -...

Detailed explanation of three ways to connect Docker containers to each other

There are three ways to interconnect and communic...

JavaScript implements displaying a drop-down box when the mouse passes over it

This article shares the specific code of JavaScri...

What are mysql dirty pages?

Table of contents Dirty pages (memory pages) Why ...

Detailed explanation of Linux mpstat command usage

1. mpstat command 1.1 Command Format mpstat [ -A ...

Analysis of 2 Token Reasons and Sample Code in Web Project Development

Table of contents question: There are 2 tokens in...

Summary of several error logs about MySQL MHA setup and switching

1: masterha_check_repl replica set error replicat...

Solution to Vue3.0 error Cannot find module'worker_threads'

I'll record my first attempt at vue3.0. When ...

React handwriting tab switching problem

Parent File import React, { useState } from '...

How to completely delete the MySQL 8.0 service under Linux

Before reading this article, it is best to have a...