Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Linux installation of mysql 8.0.19 detailed steps and problem solving

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Recently, I bought a Tencent Cloud server to build the environment.

This note is used to install mysql for the first time in a clean system that does not have mysql installed on the system. Specify the installation directory and the data file directory.

Linux system version: CentOS 7.364 bit

Install 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: confusion is not prevented. Commands are executed using absolute paths here.

Except for the # in the contents of the file, all the # here are linux commands

> mysql is a command for mysql

Steps:

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

# mkdir / software/#mkdir / data/mysql

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

-

Here I download the mysql-8.0.19-linux-glibc2.12-x86_64.tar file with router and test, so one more decompress xz

-# 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 unzipped folder name

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

4. Create mysql user groups and mysql users

# groupadd mysql#useradd-r-g mysql mysql

5. Associate myql users to mysql user groups

# 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, which comes with the system, so there is no need to install it, but the built-in dependency package will report an error.

Query whether to secretly transfer the libaio dependency package

# yum search libaio

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

# yum install libaio

8. Initialize the mysql command

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

Pay special attention to one line when executing the above command

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

Root@localhost: this is followed by the temporary password for logging in to the mysql database. The temporary password generated by each installation is different.

If the initialization Times is wrong as follows:

Error while loading shared libraries: libnuma.so.1: cannot open shared objec

Because libnuma installs 32-bit, we need 64-bit here. Execute the following statement to solve the problem

# yum install numactl.x86_64

Reinitialize the mysql command after execution

9. Start the mysql service

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

The above command to start mysql service will report an error, because the configuration file of mysql has not been modified, and the error content is roughly 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 Mysql configuration file

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

Before modification

If test-z "$basedir" thenbasedir=/usr/local/mysqlbindir=/usr/local/mysql/binif test-z "$datadir" thendatadir=/usr/local/mysql/datafisbindir=/usr/local/mysql/binlibexecdir=/usr/local/mysql/binelsebindir= "$basedir/bin" if test-z "$datadir" thendatadir= "$basedir/data" fisbindir= "$basedir/sbin" libexecdir= "$basedir/libexec" fi

After modification

If test-z "$basedir" thenbasedir=/software/mysqlbindir=/software/mysql/binif test-z "$datadir" thendatadir=/data/mysqlfisbindir=/software/mysql/binlibexecdir=/software/mysql/binelsebindir= "$basedir/bin" if test-z "$datadir" thendatadir= "$basedir/data" fisbindir= "$basedir/sbin" libexecdir= "$basedir/libexec" fi

Save exit

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

11. Modify my.cnf file

# vi / etc/my.cnf

Copy the following to replace the contents in the current my.cnf file

[client] no-beepsocket = / software/mysql/mysql.sock# pipe# socket=0.0port=3306 [mysql] # the utf8 of the original text points to UTF8MB3, and the subsequent version will be changed to UTF8MB4 One step in place default-character-set=UTF8MB4 [mysqld] basedir=/software/mysqldatadir=/data/mysqlport=3306pid-file=/software/mysql/mysqld.pid#skip-grant-tablesskip-name-resolvesocket = / software/mysql/mysql.sockcharacter-set-server=utf8default-storage-engine=INNODBexplicit_defaults_for_timestamp = true# Server Id.server-id=1max_connections=2000#query_cache_size has been removed in version 8.0, so note # query_cache_size=0table_open_cache=2000tmp_table_size=246Mthread_cache_size=300# limits the stack size for each database thread. The default setting is sufficient for most applications thread_stack = 192kkey_buffer_size=512Mread_buffer_size=4Mread_rnd_buffer_size=32Minnodb_data_home_dir = / data/mysqlinnodb_flush_log_at_trx_commit=0innodb_log_buffer_size=16Minnodb_buffer_pool_size=256Minnodb_log_file_size=128Minnodb_thread_concurrency=128innodb_autoextend_increment=1000innodb_buffer_pool_instances=8innodb_concurrency_tickets=5000innodb_old_blocks_time=1000innodb_open_files=300innodb_stats_on_metadata=0innodb_file_per_table=1innodb_checksum_algorithm=0back_log=80flush_time=0join_ Buffer_size=128Mmax_allowed_packet=1024Mmax_connect_errors=2000open_files_limit=4161#query_cache_type has been removed in version 8.0 Therefore, note # query_cache_type=0sort_buffer_size=32Mtable_definition_cache=1400binlog_row_event_max_size=8Ksync_master_info=10000sync_relay_log=10000sync_relay_log_info=10000# inserts the data cache size in bulk, which can effectively improve the insertion efficiency. The default is 8Mbulk_insert_buffer_size = 64Minteractive_timeout = 120wait_timeout = 120logMutual. The default is include all files from the config directoryinserted data cache dedir / etc/my.cnf.d.

Save exit

12. Start mysql

# / etc/init.d/mysqld start

The new version of the installation package will report an error 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 Security Startup installer only recognizes the path / usr/local/mysql.

Solution:

Method 1. Establish a soft connection

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, the one I use)

# vim / software/mysql/bin/mysqld_safe

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

Save exit. (you can copy this file out, modify it and replace it)

13. Log in to mysql

I can't log in here, but I've been denny, something like this:

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

Reference https://cloud.tencent.com/developer/article/1188636

Change to this operation:

1. Stop the mysql database

/ etc/init.d/mysqld stop

(or directly kill-9 [PID] kill process! )

two。 Execute the following command

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

3. Log in to the mysql database using root

Mysql-u root mysql

4. Update 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 back in to mysql using the root user

Mysql-uroot-p Enter password:- -# / software/mysql/bin/mysql-u root-p

Enter the temporary password. The temporary password is Article 8 root@localhost: the following

15. Change the login password of mysql

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

16. Complete, at this time, the login name of mysql, root login password, root

Summary

So far, this is the end of this article on the detailed steps of installing mysql8.0.19 in linux and how to solve the problem. for more information about installing mysql8.0.19 in linux, please search for previous articles or continue to browse the relevant articles below. I hope you will support it in the future!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report