1. Unzip the mysql compressed package to the /usr/local folder and rename it to mysql #Unzip tar -zxf mysql-5.7.27-el7-x86_64.tar.gz -C /usr/local/ #Rename cd /usr/local/ mv mysql-5.7.27-el7-x86_64/mysql
Enter mysql. Since 5.7 does not have a data directory, create one yourself. cd mysql/ mkdir data
Create mysql user and user group [root@airflow mysql]# groupadd mysql [root@airflow mysql]# useradd -r -s /sbin/nologin -g mysql mysql -d /usr/local/mysql/ #The useradd -r parameter indicates that the mysql user is a system user and cannot be used to log in to the system. 4. Change the mysql directory permissions. Previously it was root permissions, now set it to mysql permissions chown -R mysql:mysql /usr/local/mysql/
Initialize the database ./bin/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/
Put mysql into the local system service cp -a ./support-files/mysql.server /etc/init.d/mysqld 7. Since there is no my-default.cnf file in MySQL, edit the /etc/my.cnf file directly (you can also upload my-default.cnf) vi my.cnf [mysqld] basedir=/usr/local/mysql datadir=/usr/local/mysql/data socket=/tmp/mysql.sock user=mysql port=3306 character-set-server = utf8mb4 collation-server = utf8mb4_unicode_ci init_connect = 'SET NAMES utf8mb4' symbolic-links=0 max_connections=200 default-storage-engine=INNODB lower_case_table_names=1 max_allowed_packet=32M explicit_defaults_for_timestamp=true [mysqld_safe] log-error=/var/log/mysql/mysql.log pid-file=/var/run/mysql/mysql.pid Note: mysql connects to localhost usually through a Unix domain socket file, usually /tmp/mysql.sock. Do not modify the socket path, otherwise you will get an error when connecting to the local mysql: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' Because the log-error and pid-file paths are configured in my.cnf, you need to create mysql directories in /var/log/ and /var/run/ and give the mysql user full permissions (chmod) chmod -R 777 /var/log/mysql/ chmod -R 777 /var/run/mysql/ Otherwise, an error will be reported when starting, as shown below
Start mysql service
View the initial password and try to log in to MySQL
Login successful, change password SET PASSWORD FOR 'root'@localhost=PASSWORD('123456');
Configure mysql environment variables, modify the /etc/profile file, add configuration at the bottom, and add it to start automatically at boot. Add the following configuration: Effective immediately 12. Automatic startup configuration chmod +x /etc/init.d/mysqld chkconfig --add mysqld chkconfig --list If you see the mysql service and 3, 4, and 5 are all on, then it is successful. If they are off, type Then restart your computer Check the running status of MySQL
Allow root account IP login mysql -u root -p use mysql; update user set host = '%' where user = 'root'; FLUSH PRIVILEGES; Configuration file example [mysqld] socket=/var/lib/mysql/mysql.sock port = 3306 basedir=/softwares/mysql_5727 datadir=/softwares/mysql_5727/data max_connections=200 character-set-server=utf8mb4 default-storage-engine=INNODB lower_case_table_names=1 max_allowed_packet=32M explicit_defaults_for_timestamp=true You may also be interested in:
|
<<: How to view files in Docker image
>>: Play and save WeChat public account recording files (convert amr files to mp3)
Table of contents 1. The default focus is on the ...
Preface We often need to do something based on so...
System tray icons are still a magical feature tod...
Location means "positioning", which is ...
Before we begin, we create two tables to demonstr...
Note 1: Solve the problem of slow connection to M...
1. Navigation: Unordered List vs. Other Label Ele...
1 Create a user and specify the user's root p...
First, let's talk about the in() query. It is...
This article shares a native JS implementation of...
The pre element defines preformatted text. Text en...
Preface: I have always wanted to know how a SQL s...
Original URL: http://segmentfault.com/blog/ciaocc/...
1. Check whether the check status module is insta...
Table of contents 1. Calculated properties 1.1 Ba...