The latest tutorial for installing MySQL 8.0.25 on Linux is for your reference. The specific contents are as follows I installed MySQL on the server myself and collected a lot of materials, but most of them took a long time. The latest download and installation methods have many differences, and I also stepped on many pitfalls. So I sorted out my entire installation process, and you can refer to it. downloadOnline Installation
Offline installation First go to the official website to download the installation file, the latest download MySQL Download Address Select the appropriate installation package to download according to the number of server bits Attached is the Linux command to check the number of bits getconf LONG_BIT Use ftp to upload the installation file Unziptar -xvf mysql-8.0.25-linux-glibc2.12-x86_64.tar.xz Later, when configuring environment variables and database configuration, the decompression path is too long Modify the default folder name. I modified it through the ftp tool. The command is attached below. mv mysql-8.0.25-linux-glibc2.12-x86_64 /home/mysql-8.0.25 #Detailed explanation: mv The folder name where the current file name is modified Create a data directory# 1. Create a folder mkdir -p /data/mysqldata/ #2 Create a database user. You will need it for file configuration and initialization later. If you have other users, you don’t need to create a new one. #2.1 Create a user group groupadd mysql #2.2 Create user useradd -r -g mysql mysql #Give permissions 2. chown mysql:mysql -R /data/mysqldata #chown username:usergroup-R /data/mysqldata 3. chmod 750 /data/mysqldata/ -R Configure the environmentvim /etc/profile #If your system does not support vim command, use the following vi /etc/profile #Edit, add the following code to the last line of the document export PATH=$PATH:your MySQL decompression path/mysql-8.0.25/bin:your MySQL decompression path/mysql-8.0.25/lib Edit my.cnf#1. Edit the my.cnf file vim /etc/my.cnf #or vi /etc/my.cnf #2. Press insert to enter edit mode and add the following script [mysql] # Client default character set default-character-set=utf8mb4 [client] port=3306 socket=/var/lib/mysql/mysql.sock [mysqld] port=3306 server-id=3306 user=mysql datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock # Set the installation directory of mysql basedir=/home/mysql-8.0.25 # Your own installation path # Set the storage directory of mysql database datadatadir=/data/mysqldata/mysql # The storage path of the database file you created yourself log-bin=/data/mysqldata/mysql/mysql-bin innodb_data_home_dir=/data/mysqldata/mysql innodb_log_group_home_dir=/data/mysqldata/mysql character-set-server=utf8mb4 lower_case_table_names=1 autocommit=1 # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 # Settings user and group are ignored when systemd is used. # If you need to run mysqld under a different user or group, # customize your systemd unit file for mariadb according to the # instructions in http://fedoraproject.org/wiki/Systemd [mysqld_safe] #Set the storage directory of mysql database log and process data log-error=/data/mysqldata/mysql/mysql.log pid-file=/data/mysqldata/mysql/mysql.pid Initialize MySQL1. cd /home/mysql-8.0.25/bin/ 2. ./mysqld --defaults-file=/etc/my.cnf --basedir=/home/mysql-8.0.25/ --datadir=/data/mysqldata/mysql --user=mysql --initialize #Parameter Details --defaults-file=/etc/my.cnf specifies the configuration file (must be placed first, at least before --initialize) --user=mysql specifies the user (very important) --basedir=/home/mysql-8.0.25/ specifies the installation directory --datadir=/data/mysqldata/mysql/ specifies the initialization data directory After initializing the database, a temporary password will be given. Please save it locally. It will be used when you log in to the database for the first time. Start MySQL# 1. Copy the mysql.server file cp /home/mysql-8.0.25/support-files/mysql.server /etc/init.d/mysql cp /home/mysql-8.0.25/support-files/mysql.server /etc/init.d/mysqld # 2. Grant permissions chown 777 /etc/my.cnf chmod +x /etc/init.d/mysql chmod +x /etc/init.d/mysqld # 3. Check if /var/lib/mysql exists. If not, create it. mkdir /var/lib/mysql #Keep the directory consistent with my.cnf. # 4. Grant permissions. chown -R mysql:mysql /var/lib/mysql/ #Keep the directory consistent with my.cnf. # 5. Start the database. service mysql start #Or systemctl mysql start Startup Success mysql database settingsChange the initial password mysql -u root -p or #Enter the installation directory cd /home/mysql-8.0.25/bin # Execute the command ./mysql -uroot -p Enter the temporary password saved locally Change Password # Change the root password. Change the root user to only be able to connect locally. ALTER USER 'root'@'localhost' IDENTIFIED with mysql_native_password BY 'new password'; #Flush privileges; Create User #Create a user for any remote accessCREATE user 'mysql'@'%'; #Change password alter user 'mysql'@'%' identified with mysql_native_password by 'new password'; Create a database create database test default character set utf8mb4 collate utf8mb4_unicode_ci; #create database database name default character set utf8mb4 collate utf8mb4_unicode_ci; Authorization #Grant all privileges on test database to mysql user grant all privileges on test.* to "mysql"@"%"; #Flush privileges; examine Use navicat to test whether the database is connected normally Extension (MySQL starts automatically at boot)#1. Check if there is mysql service chkconfig --list #2. Enter the mysql software directory and copy the mysql.server file to the /etc/rc.d/init.d directory cp /home/mysql-8.0.25/support-files/mysql.server /etc/rc.d/init.d/mysql #3. Grant executable permissions to /etc/rc.d/init.d/mysql chmod +x /etc/rc.d/init.d/mysql #4. Add mysql service chkconfig --add mysql #5. Enable mysql service to start automatically at boot time chkconfig --level 345 mysql on #6. Check the MySQL service, restart the server, and test whether it is successful. chkconfig --list Added successfully For more tutorials about MySQL, please click on the topic: "MySQL different versions installation tutorial" 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:
|
<<: Common parameters of IE web page pop-up windows can be set by yourself
>>: Website Building Tutorial for Beginners: Learn to Build a Website in Ten Days
Table of contents Component Communication Introdu...
Scenario: The data in a table needs to be synchro...
This article records the installation of MySQL 8....
After the changes: innodb_buffer_pool_size=576M -...
The specific code for using jQuery to implement t...
MySQL InnoDB monitoring (system layer, database l...
Table of contents 0x0 Introduction 0x1 RBAC Imple...
When MySQL queries tens of millions of data, most...
Table of contents Overview Button-level permissio...
To install a virtual machine on a Windows system,...
Table of contents 1. What is an index? 2. Why do ...
This article shares the specific code of vue unia...
1. There are generally two methods for Vue routin...
Table of contents background Problem Analysis 1. ...
There is no data directory, my-default.ini and my...