MySQL 5.7.17 installation and configuration tutorial under CentOS6.9

MySQL 5.7.17 installation and configuration tutorial under CentOS6.9

CentOS6.9 installs Mysql5.7 for your reference, the details are as follows

1. Upload the installation package

2. Create users and mysql directories

1. Create a mysql group

Enter the command: groupadd mysql

2. Create a mysql user and put it in the mysql group

Enter the command: useradd -r -g mysql mysql

3. Set a password for the mysql user

Enter the command: passwd mysql

3. Unzip Mysql

1. Copy the tarball to the /usr/local/mysql directory

2. Decompression

tar -zxvf mysql.tar

3. Rename the unzipped file to mysql

4. Configure related startup files

1. Copy my_default.cnf to /etc/my.cnf (automatically read when mysql starts)

Back up my.cnf

Copy my.cnf

2. Solve the garbled problem

Enter the command: vi /etc/my.cnf

Change:

[mysql]
default-character-set=utf8
[mysqld]
default-storage-engine=INNODB
character_set_server=utf8

3. Copy mysql.server to /etc/init.d/

4. Modify the /etc/init.d/mysql parameters to give two directory locations

Enter the command: vim /etc/init.d/mysql

Change: basedir=/usr/local/mysql

datadir=/usr/local/mysql/data

5. Change the owner of the directory /usr/local/mysql

Enter the command: chown -R mysql:mysql /usr/local/mysql/

5. Initialize the database

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

New command: ./mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

6. Start the database

Enter the command: ./mysqld_safe --user=mysql &

& symbol: throw the current process to the background

7. Change Password

View the password automatically generated by initialization: cat /root/.mysql_secret

Enter mysql: bin/mysql -uroot -p (paste the password you just copied)

Reset root password after logging in

mysql> SET PASSWORD FOR 'root'@localhost = PASSWORD('123456');

8. Connecting to the virtual machine database on this machine

Check whether only root localhost permissions are authorized. If so, remote access cannot connect

mysql> select Host, User, Password from mysql.user;

Grant % permissions to root

mysql> update user set host = '%' where host = 'localhost';

mysql> flush privileges;

Finish!

IX. Problem

1. ./mysqld_safe: line 586: /var/lib/mysql/mysqld_safe.pid: No such file or directory

Solution:

(1) Because there is no error log during the investigation, we temporarily use the method of supplementing the directory

mkdir -p /var/lib/mysql

chown mysql:mysql /var/lib/mysql

(2) After adding the directory, the error message Can't open and lock privilege tables: Table 'mysql.user' doesn't exist appears

Error in datadir path in My.ini Change path

2.mysqld_safe mysqld from pid file /usr/local/mysql/localhost.pid ended

Query log: Found: The error means mysqld does not have the access rights to the directory.

Change permissions: chmod -R 777

A new problem occurred: Can't open the mysql.plugin table. Please run mysql_upgrade to create it.

Solution: Reinitialize using the old command

3. Starting MySQL..... ERROR! The server quit without updating PID file (/usr/local/mysql/centos6.9.wzy.com.pid).

Problem: character_set_server=utf8 is written incorrectly in my.ini

When I fixed the problem before, my.ini was changed incorrectly datadir=/usr/local/mysql/data

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • MySQL 5.7 installation and configuration tutorial under CentOS7 64 bit
  • Detailed steps to install MySQL on CentOS 7
  • A concise tutorial on how to install mysql5.7 decompressed version on CentOS7
  • Centos7 installation and configuration of Mysql5.7
  • Detailed tutorial on installing Mysql5.7.19 on Centos7 under Linux
  • How to install mysql5.6 on centos7
  • Centos7 install mysql5.6.29 shell script
  • How to install MySQL on CentOS 7 and set it to start automatically
  • The process of installing MySQL 8.0.26 on CentOS7

<<:  jQuery plugin to implement stacked menu

>>:  Summary of methods to check whether the port is open in Linux

Recommend

Detailed explanation of the use cases of Vue listeners

The first one is to use jQuery's ajax to send...

Detailed installation and uninstallation tutorial for MySQL 8.0.12

1. Installation steps for MySQL 8.0.12 version. 1...

Nginx service 500: Internal Server Error one of the reasons

500 (Internal Server Error) The server encountere...

Some common advanced SQL statements in MySQL

MySQL Advanced SQL Statements use kgc; create tab...

Summary of learning Docker commands in one article

Table of contents Introduction Mirror repository ...

JS version of the picture magnifying glass effect

This article shares the specific code of JS to ac...

MySQL million-level data paging query optimization solution

When there are tens of thousands of records in th...

MySQL 4 common master-slave replication architectures

Table of contents One master and multiple slaves ...

JavaScript to implement the aircraft war game

This article shares with you how to use canvas an...

React gets input value and submits 2 methods examples

Method 1: Use the target event attribute of the E...

Use of MySQL SHOW STATUS statement

To do MySQL performance adjustment and service st...

Linux uses lsof command to check file opening status

Preface We all know that in Linux, "everythi...