Home Database Mysql Tutorial Tutorial for Centos7 to install Mysql5.7.19 under Linux (picture)

Tutorial for Centos7 to install Mysql5.7.19 under Linux (picture)

Sep 02, 2017 pm 01:37 PM
centos7 linux

This article mainly introduces the detailed tutorial of installing Mysql5.7.19 on Centos7 under Linux. Friends in need can refer to it

1. Download mysql

2. Select the source code package and click to download the general version

You can download it directly without logging in

3. Unzip and compile


##

1

2

tar -zxvf mysql-5.7.19.tar.gz

cd mysql-5.7.19.tar.gz

Copy after login

Create data directory

mkdir -p / data/mysql

Compile with cmake first. If you don’t have this command, you need to install yum first


1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql/  #这个是编译安装之后的mysql目录所在地,可自行更改

-DMYSQL_DATADIR=/data/mysql/    #这个指向数据目录

-DMYSQL_UNIX_ADDR=/tmp/mysql.sock

-DSYSCONFDIR=/usr/local/mysql-5.7/conf/

-DWITH_MYISAM_STORAGE_ENGINE=1

-DWITH_INNOBASE_STORAGE_ENGINE=1

-DWITH_BLACKHOLE_STORAGE_ENGINE=1

-DWITH_ARCHIVE_STORAGE_ENGINE=1

-DWITH_MEMORY_STORAGE_ENGINE=1

-DWITH_READLINE=1

-DMYSQL_TCP_PORT=3306

-DENABLED_LOCAL_INFILE=1

-DDEFAULT_CHARSET=utf8

-DDEFAULT_COLLATION=utf8_general_ci

-DMYSQL_USER=mysql

-DWITH_SSL=system

-DWITH_ZLIB=system -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/usr/local/boost #从MySQL 5.7.5开始Boost库是必需安装的

Copy after login

After compilation

make && make install A long wait....The installation will be completed after that

After the installation is completed, there will be a directory mysql under the path /usr/local/. This directory is the path where I compiled and installed the settings-


1

DCMAKE_INSTALL_PREFIX=/usr/local/mysql/

Copy after login

Generally for security reasons, we will create a mysql user and mysql group and execute the following commands


1

2

3

4

5

#添加用户组

groupadd mysql

#添加用户mysql 到用户组mysql

useradd

-g mysql mysql

Copy after login

Give mysql permissions


1

2

3

4

5

chown -R mysql:mysql mysql

#添加用户组

groupadd mysql

#添加用户mysql 到用户组mysql

useradd -g mysql mysql

Copy after login

Give mysql permission


1

chown -R mysql:mysql mysql

Copy after login

4. Next configure the startup direction and set the boot startup

Configuration

/ect/my.cnf, if there is no my.cnf, you can create and add it yourself, for reference only


1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

[client]

ort = 3306

ocket = /tmp/mysql.sock

default-character-set = utf8mb4

[mysqld]

ort = 3306

ocket = /tmp/mysql.sock

asedir = /usr/local/mysql

datadir = /data/mysql

id-file = /data/mysql/mysql.pid

user = mysql

ind-address = 0.0.0.0

erver-id = 1

init-connect = 'SET NAMES utf8mb4'

character-set-server = utf8mb4

#skip-name-resolve

#skip-networking

ack_log = 300

max_connections = 1000

max_connect_errors = 6000

open_files_limit = 65535

table_open_cache = 128

max_allowed_packet = 4M

inlog_cache_size = 1M

max_heap_table_size = 8M

tmp_table_size = 16M

read_buffer_size = 2M

read_rnd_buffer_size = 8M

ort_buffer_size = 8M

join_buffer_size = 8M

key_buffer_size = 4M

thread_cache_size = 8

query_cache_type = 1

query_cache_size = 8M

query_cache_limit = 2M

ft_min_word_len = 4

log_bin = mysql-bi

inlog_format = mixed

expire_logs_days = 30

log_error = /data/mysql/mysql-error.log

low_query_log = 1

long_query_time = 1

low_query_log_file = /data/mysql/mysql-slow.log

erformance_schema = 0

explicit_defaults_for_timestam

#lower_case_table_names = 1

kip-external-locking

default_storage_engine = InnoDB

#default-storage-engine = MyISAM

innodb_file_per_table = 1

innodb_open_files = 500

innodb_buffer_pool_size = 64M

innodb_write_io_threads = 4

innodb_read_io_threads = 4

innodb_thread_concurrency = 0

innodb_purge_threads = 1

innodb_flush_log_at_trx_commit = 2

innodb_log_buffer_size = 2M

innodb_log_file_size = 32M

innodb_log_files_in_group = 3

innodb_max_dirty_pages_pct = 90

innodb_lock_wait_timeout = 120

ulk_insert_buffer_size = 8M

myisam_sort_buffer_size = 8M

myisam_max_sort_file_size = 10G

myisam_repair_threads = 1

interactive_timeout = 28800

wait_timeout = 28800

[mysqldump]

quick

max_allowed_packet = 16M

[myisamchk]

key_buffer_size = 8M

ort_buffer_size = 8M

read_buffer = 4M

write_buffer = 4M

Copy after login

Next, execute the initialization database statement:

Note

mysql_install_db is no longer recommended. It is recommended to change to mysqld –initialize to complete the instance initialization.


1

/usr/local/mysql/bin/mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql

Copy after login
Copy after login

This step is very important. If you start the database directly without initialization, an error will be reported

ERROR! The server quit without updating PID file (/data/mysql/ mysql.pid).

If the initialization fails or the following error is reported, you need to clear your /data/mysql directory first. Because there is data under the mysql directory, the initialization execution is aborted.

2017-08-29T13:39:47.241469Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.2017-08-29T13:39:47.241536Z 0 [ERROR] Aborting

Clear and then re-initialize


1

/usr/local/mysql/bin/mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql

Copy after login
Copy after login

Now you can start mysql


1

ervice mysqld start

Copy after login

Log in Test


1

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

Copy after login

Because initialization

--initialize-insecure does not have a password by default, so you can directly confirm the password without entering it;

If an error is reported when logging in


1

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

Copy after login

Check whether you have successfully started the database or not.

ps -ef | grep mysql Check whether the process is started

An empty password is not safe, so we still need to set a password. \"root\" in the following command is to set the password area. My password is set to root, which can be modified by yourself


1

[root@localhost local]# /usr/local/mysql/bin/mysql -e "grant all privileges on *.* to root@'127.0.0.1' identified by \"root\" with grant option;"[root@localhost local]# /usr/local/mysql/bin/mysql -e "grant all privileges on *.* to root@'localhost' identified by \"root\" with grant option;"

Copy after login

Next, log in again and test if the password change is successful, it’s done!

Summarize

The above is the detailed content of Tutorial for Centos7 to install Mysql5.7.19 under Linux (picture). For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1660
14
PHP Tutorial
1260
29
C# Tutorial
1233
24
Linux Architecture: Unveiling the 5 Basic Components Linux Architecture: Unveiling the 5 Basic Components Apr 20, 2025 am 12:04 AM

The five basic components of the Linux system are: 1. Kernel, 2. System library, 3. System utilities, 4. Graphical user interface, 5. Applications. The kernel manages hardware resources, the system library provides precompiled functions, system utilities are used for system management, the GUI provides visual interaction, and applications use these components to implement functions.

vscode terminal usage tutorial vscode terminal usage tutorial Apr 15, 2025 pm 10:09 PM

vscode built-in terminal is a development tool that allows running commands and scripts within the editor to simplify the development process. How to use vscode terminal: Open the terminal with the shortcut key (Ctrl/Cmd). Enter a command or run the script. Use hotkeys (such as Ctrl L to clear the terminal). Change the working directory (such as the cd command). Advanced features include debug mode, automatic code snippet completion, and interactive command history.

How to check the warehouse address of git How to check the warehouse address of git Apr 17, 2025 pm 01:54 PM

To view the Git repository address, perform the following steps: 1. Open the command line and navigate to the repository directory; 2. Run the "git remote -v" command; 3. View the repository name in the output and its corresponding address.

Where to write code in vscode Where to write code in vscode Apr 15, 2025 pm 09:54 PM

Writing code in Visual Studio Code (VSCode) is simple and easy to use. Just install VSCode, create a project, select a language, create a file, write code, save and run it. The advantages of VSCode include cross-platform, free and open source, powerful features, rich extensions, and lightweight and fast.

vscode terminal command cannot be used vscode terminal command cannot be used Apr 15, 2025 pm 10:03 PM

Causes and solutions for the VS Code terminal commands not available: The necessary tools are not installed (Windows: WSL; macOS: Xcode command line tools) Path configuration is wrong (add executable files to PATH environment variables) Permission issues (run VS Code as administrator) Firewall or proxy restrictions (check settings, unrestrictions) Terminal settings are incorrect (enable use of external terminals) VS Code installation is corrupt (reinstall or update) Terminal configuration is incompatible (try different terminal types or commands) Specific environment variables are missing (set necessary environment variables)

vscode Previous Next Shortcut Key vscode Previous Next Shortcut Key Apr 15, 2025 pm 10:51 PM

VS Code One-step/Next step shortcut key usage: One-step (backward): Windows/Linux: Ctrl ←; macOS: Cmd ←Next step (forward): Windows/Linux: Ctrl →; macOS: Cmd →

What is the main purpose of Linux? What is the main purpose of Linux? Apr 16, 2025 am 12:19 AM

The main uses of Linux include: 1. Server operating system, 2. Embedded system, 3. Desktop operating system, 4. Development and testing environment. Linux excels in these areas, providing stability, security and efficient development tools.

How to run sublime after writing the code How to run sublime after writing the code Apr 16, 2025 am 08:51 AM

There are six ways to run code in Sublime: through hotkeys, menus, build systems, command lines, set default build systems, and custom build commands, and run individual files/projects by right-clicking on projects/files. The build system availability depends on the installation of Sublime Text.

See all articles