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)
In actual work or interviews, we often encounter ...
As shown below: As shown above, just replace it. ...
Mysql stored procedure 1. Create stored procedure...
When the page is not responding, displaying the l...
1 Background Recently, some performance issues ha...
First of all, what is 404 and soft 404? 404: Simpl...
Special statement: This article is translated bas...
When developing a web project, you need to instal...
Introduction to Swap Swap (i.e. swap partition) i...
One purpose Select a local folder on the Html pag...
Before webpack packaging, we must ensure that the...
View the IP address of the Container docker inspe...
This article uses examples to illustrate the prin...
The following example code introduces the princip...
Quickly install the tensorflow environment in Doc...