The specific steps to install mysql

1. Download the mysql tar package (pay attention to the size of the package and whether it is 32bit or 64bit)
2. Enter cd /usr/local/
3. Unzip mysql and rename it to mysql (this step is very important, because the following configurations are all configured with mysql ) (tar xvf mysql-5.7.21-linux-glibc2.12-x86_64.tar.gz) (mv mysql-5.7.21-linux-glibc2.12-x86_64 mysql rename)


4.groupadd mysql
5.useradd - r -g mysql mysql


6.chown -R mysql mysql/ (To perform this step, you need to enter the local directory, so that there is a mysql folder in this directory)
7.chgrp -R mysql mysql/ (To perform this step, you need to enter the local directory, I think there is a mysql folder in this directory)
8. The my.cnf file is common under /etc (very important, the configuration of mysql is configured here) (create my.cnf file touch /etc/my.cnf)
8. Enter etc /my.cnf(vi /etc/my.cnf)
9. Assign the following content with my.cnf
[client]
port = 3306
socket = /tmp/mysql.sock


[mysqld]
character_set_server=utf8
init_connect='SET NAMES utf8'
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
socket=/tmp/mysql.sock
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld .pid
skip-grant-tables
lower_case_table_names = 1


sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION


max_connections=5000


default-time_zone = '+8:00'
10.#Install this stuff first, or initialize it May report an error
yum install libaio #Edit
the log file manually, do not write anything, save and exit directly
cd /var/log/
vim mysqld.log
: wq
chmod 777 mysqld.log (you need to enter the /var/log directory to perform this step , that there is mysqld.log in this directory)
chown mysql:mysql mysqld.log (to execute this step, you need to enter the /var/log directory, so that there is mysqld.log in this directory)
/usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --lc_messages_dir=/usr/local/mysql /share --lc_messages=en_US
11. View the initialization password cat /var/log/mysqld.log
12.
/usr/local/mysql/support-files/mysql.server start Start the service


13.
/usr/local/mysql/bin /mysql -uroot -p The initial password you saw above


14. Reset the password (under # is understanding, 14.1, 14.2, 14.3 are steps)
#set password for 'root'@'localhost'=password( 'root'); (error ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement) (you need to flush #privileges; and reset the password Yes, just remove skip-grant-tables in my.cnf)
14.1: (set password for 'root'@'localhost'=password('root');)
14.2 (flush privileges;)
14.3 (set password for 'root'@'localhost'=password('root');)
14.4 Remove skip-grant-tables in my.cnf
14.5 Restart mysql
/usr/local/mysql/support-files/mysql. server reload 


15. Allow others to access 
the following sql statements through the network, so you need to log in to mysql to execute #Add
remote user (running on linux)
create user 'root'@'%' identified by 'root';
#authorize
grant all on * .* to 'root'@'%' with grant option; #Refresh
privileges
flush privileges;


15. Use the client to log in to mysql to close the firewall
systemctl stop firewalld.service

















Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324684436&siteId=291194637