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/ 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 If it is not installed, you can install it with the following command 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:
Because libnuma is installed in 32 bits, we need 64 bits here, and we can solve it by executing the following statement Reinitialize mysql command after execution 9. Start mysql service 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:
10. Modify the Mysql configuration file 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 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 The new version of the installation package will report an error, the error content is as follows:
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) 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:
Refer to https://cloud.tencent.com/developer/article/1188636 Change this operation to: 1. Stop the mysql database (Or just kill -9 [PID] to kill the process!) 2. Execute the following command 3. Log in to the MySQL database as root 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 6. Exit mysql mysql> quit 7. Restart mysql 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:
|
<<: Summary of Linux Logical Volume Management (LVM) usage
>>: WeChat applet development realizes the home page pop-up box activity guidance function
Table of contents 1. beforeCreate & created 2...
cause The way to import external files into a min...
Table of contents Table/index.js Table/model/inde...
Table of contents Enter the topic mysql add, dele...
MySQL trigger simple example grammar CREATE TRIGG...
Table of contents 1. Install and create an instan...
I recently upgraded MySQL to 5.7, and WordPress r...
1. Go to the official website www.mysql.com and s...
With the development of Internet technology, user...
Table of contents 1. Number in JavaScript 2. Math...
This article shares the specific code of JS to ac...
Optimize queries Use the Explain statement to ana...
Hello everyone, today we are going to learn about...
First, let’s take a look at the picture: Today we...
Mainly used knowledge points: •css3 3d transforma...