Detailed steps and problem solving methods for installing MySQL 8.0.19 on Linux

Detailed steps and problem solving methods for installing MySQL 8.0.19 on Linux

I recently bought a Tencent Cloud server and built an environment.

This note is used to install MySQL for the first time on a clean system that has never had MySQL installed on it. Specify the installation directory and data file directory yourself.

Linux system version: CentOS 7.3 64-bit

Installation source file version: mysql-5.7.21-linux-glibc2.12-x86_64.tar.gz

mysql installation location: /software/mysql

Database file data location: /data/mysql

Note: To prevent confusion, the absolute path is used to execute the command here.

Except for the # in the file content, all the # here are Linux commands

>mysql is the mysql command

step:

1. Create the folder software and database data file /data/mysql in the root directory

#mkdir /software/
#mkdir /data/mysql

2. Upload the mysql-8.0.19-linux-glibc2.12-x86_64.tar.xz file to /software

--------------------

Here I downloaded the mysql-8.0.19-linux-glibc2.12-x86_64.tar file with router and test, so I need to unzip it.

--------------------
#cd /software/
#xz -d mysql-8.0.19-linux-glibc2.12-x86_64.tar.xz
#tar -xvf mysql-8.0.19-linux-glibc2.12-x86_64.tar

3. Change the name of the unzipped folder

#mv /software/mysql-8.0.19-linux-glibc2.12-x86_64/ /software/mysql

4. Create mysql user group and mysql user

#groupadd mysql

#useradd -r -g mysql mysql

5. Associate the myql user to the mysql user group

#chown -R mysql:mysql /software/mysql/
#chown -R mysql:mysql /data/mysql/
#chown -R mysql /software/mysql/
#chown -R mysql /data/mysql

6. Change the permissions of the mysql installation folder mysql/

#chmod -R 755 /software/mysql/

7. Install the libaio dependency package. The system comes with this dependency package so it does not need to be installed, but the built-in dependency package will report an error

Check whether libaio dependency packages are secretly transferred

#yum search libaio

If it is not installed, you can install it with the following command

#yum install libaio

8. Initialize mysql command

#cd /software/mysql/bin
#./mysqld --user=mysql --basedir=/software/mysql --datadir=/data/mysql --initialize

When executing the above command, pay special attention to one line

[Note] A temporary password is generated for root@localhost: o*s#gqh)F4Ck

root@localhost: followed by the temporary password for logging into the MySQL database. The temporary password generated by each installation is different.

If the initialization error is as follows:

error while loading shared libraries: libnuma.so.1: cannot open shared object

Because libnuma is installed in 32 bits, we need 64 bits here, and we can solve it by executing the following statement

#yum install numactl.x86_64

Reinitialize mysql command after execution

9. Start mysql service

# sh /software/mysql/support-files/mysql.server start

The above command to start the MySQL service will report an error because the MySQL configuration file has not been modified. The error content is as follows:

./support-files/mysql.server: line 239: my_print_defaults: command not found

./support-files/mysql.server: line 259: cd: /usr/local/mysql: No such file or directory

Starting MySQL ERROR! Couldn't find MySQL server (/usr/local/mysql/bin/mysqld_safe)

10. Modify the Mysql configuration file

#vim /software/mysql/support-files/mysql.server

Before modification

if test -z "$basedir"
then
basedir=/usr/local/mysql
bindir=/usr/local/mysql/bin
if test -z "$datadir"
then
datadir=/usr/local/mysql/data
fi
sbindir=/usr/local/mysql/bin
libexecdir=/usr/local/mysql/bin
else
bindir="$basedir/bin"
if test -z "$datadir"
then
datadir="$basedir/data"
fi
sbindir="$basedir/sbin"
libexecdir="$basedir/libexec"
fi

After

if test -z "$basedir"
then
basedir=/software/mysql
bindir=/software/mysql/bin
if test -z "$datadir"
then
datadir=/data/mysql
fi
sbindir=/software/mysql/bin
libexecdir=/software/mysql/bin
else
bindir="$basedir/bin"
if test -z "$datadir"
then
datadir="$basedir/data"
fi
sbindir="$basedir/sbin"
libexecdir="$basedir/libexec"
fi

Save and exit

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

#chmod 755 /etc/init.d/mysqld

11. Modify the my.cnf file

#vi /etc/my.cnf

Copy the following content to replace the current my.cnf file

[client]
no-beep
socket =/software/mysql/mysql.sock
#pipe
# socket=0.0
port=3306
[mysql]
#The original utf8 points to UTF8MB3. The subsequent version needs to be changed to UTF8MB4. Let's do it in one step. default-character-set=UTF8MB4
[mysqld]
basedir=/software/mysql
datadir=/data/mysql
port=3306
pid-file=/software/mysql/mysqld.pid
#skip-grant-tables
skip-name-resolve
socket = /software/mysql/mysql.sock
character-set-server=utf8
default-storage-engine=INNODB
explicit_defaults_for_timestamp = true
# Server Id.
server-id=1
max_connections=2000
#query_cache_size has been removed in version 8.0, so comment #query_cache_size=0
table_open_cache=2000
tmp_table_size=246M
thread_cache_size=300
#Limit the stack size used for each database thread. The default setting is sufficient for most applications thread_stack = 192k
key_buffer_size=512M
read_buffer_size=4M
read_rnd_buffer_size=32M
innodb_data_home_dir = /data/mysql
innodb_flush_log_at_trx_commit=0
innodb_log_buffer_size=16M
innodb_buffer_pool_size=256M
innodb_log_file_size=128M
innodb_thread_concurrency=128
innodb_autoextend_increment=1000
innodb_buffer_pool_instances=8
innodb_concurrency_tickets=5000
innodb_old_blocks_time=1000
innodb_open_files=300
innodb_stats_on_metadata=0
innodb_file_per_table=1
innodb_checksum_algorithm=0
back_log=80
flush_time=0
join_buffer_size=128M
max_allowed_packet=1024M
max_connect_errors=2000
open_files_limit=4161
#query_cache_type has been removed in version 8.0, so comment #query_cache_type=0
sort_buffer_size=32M
table_definition_cache=1400
binlog_row_event_max_size=8K
sync_master_info=10000
sync_relay_log=10000
sync_relay_log_info=10000
#Batch insert data cache size can effectively improve insertion efficiency, the default is 8M
bulk_insert_buffer_size = 64M
interactive_timeout = 120
wait_timeout = 120
log-bin-trust-function-creators=1
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
#
# include all files from the config directory
#
!includedir /etc/my.cnf.d

Save and exit

12. Start MySQL

#/etc/init.d/mysqld start

The new version of the installation package will report an error, the error content is as follows:

Starting MySQL.Logging to '/data/mysql/SZY.err'.
2018-07-02T10:09:03.779928Z mysqld_safe The file /usr/local/mysql/bin/mysqld
does not exist or is not executable. Please cd to the mysql installation
directory and restart this script from there as follows:
./bin/mysqld_safe&
See http://dev.mysql.com/doc/mysql/en/mysqld-safe.html for more information
ERROR! The server quit without updating PID file (/software/mysql/mysqld.pid).

Because the new version of MySQL secure boot installation package only recognizes the path /usr/local/mysql.

Solution:

Method 1: Create a soft link

example

#cd /usr/local/mysql
#ln -s /sofware/mysql/bin/myslqd mysqld

Method 2: Modify the mysqld_safe file (this is recommended by students with obsessive-compulsive disorder, and this is what I use)

# vim /software/mysql/bin/mysqld_safe

Change all /usr/local/mysql to /software/mysql

Save and exit. (You can copy this file, modify it and then replace it)

13. Log in to MySQL

I can't log in here, I'm blocked, errors like this:

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO).

Refer to https://cloud.tencent.com/developer/article/1188636

Change this operation to:

1. Stop the mysql database

/etc/init.d/mysqld stop

(Or just kill -9 [PID] to kill the process!)

2. Execute the following command

mysqld_safe --user=mysql --skip-grant-tables --skip-networking &

3. Log in to the MySQL database as root

mysql -u root mysql

4. Update the root password

For the latest version of MySQL, please use the following SQL:

mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'newpassword';

5. Refresh permissions

mysql> FLUSH PRIVILEGES;

6. Exit mysql

mysql> quit

7. Restart mysql

/etc/init.d/mysqld restart

8. Log in to mysql again using the root user

mysql -uroot -p
 Enter password: <Enter the new password newpassword>
---------------------------------------------------------------------------------------------------------------------------
#/software/mysql/bin/mysql -u root –p

14. Enter a temporary password. The temporary password is the content after the 8th root@localhost:

15. Change the mysql login password

>mysql set password=password('root');
>mysql grant all privileges on *.* to root@'%' identified by 'root';
>mysql flush privileges;

16. Completed. At this time, the login name of MySQL is root and the login password is root

Summarize

This is the end of this article about the detailed steps and problem solving methods for installing MySQL 8.0.19 on Linux. For more information about installing MySQL 8.0.19 on Linux, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Linux system MySQL8.0.19 quick installation and configuration tutorial diagram
  • Tutorial diagram of installing mysql8.0.18 under linux (Centos7)
  • MySQL 8.0.18 installation and configuration method graphic tutorial (linux)
  • mysql-5.7.28 installation tutorial in Linux
  • Detailed tutorial on installing MySQL database in Linux environment

<<:  Summary of Linux Logical Volume Management (LVM) usage

>>:  WeChat applet development realizes the home page pop-up box activity guidance function

Recommend

Linux implements the source code of the number guessing game

A simple Linux guessing game source code Game rul...

ThingJS particle effects to achieve rain and snow effects with one click

Table of contents 1. Particle Effects 2. Load the...

Do you know how to use mock in vue project?

Table of contents first step: The second step is ...

Object.entries usage you don't know in JavaScript

Table of contents Preface 1. Use for...of to iter...

Solution to mysql prompt "got timeout reading communication packets"

Error message: user: 'root' host: `localh...

Native JS to implement hover drop-down menu

JS implements a hover drop-down menu. This is a s...

Use of Docker UI, a Docker visualization management tool

1. Introduction to DockerUI DockerUI is based on ...

Semantics: Is Html/Xhtml really standards-compliant?

<br />Original text: http://jorux.com/archiv...

Detailed explanation of Vue3's sandbox mechanism

Table of contents Preface Browser compiled versio...

MySQL detailed explanation of isolation level operation process (cmd)

Read uncommitted example operation process - Read...

Vue Router vue-router detailed explanation guide

Chinese documentation: https://router.vuejs.org/z...

How to quickly use mysqlreplicate to build MySQL master-slave

Introduction The mysql-utilities toolset is a col...

Advertising skills in the Baidu Union environment (graphic tutorial)

Recently, students from the User Experience Team o...

How to use css overflow: hidden (overflow hiding and clearing floats)

Overflow Hide It means hiding text or image infor...

ReactJs Basics Tutorial - Essential Edition

Table of contents 1. Introduction to ReactJS 2. U...