Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

CentOS 7 tutorial on installing unzipped mysql5.7

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

1. Extract the mysql package to the / usr/local folder and rename it to mysql.

# decompression

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

2 、

Enter mysql. Since there is no data directory in 5.7, create one yourself.

Cd mysql/mkdir data

3 、

Create mysql users and user groups

[root@airflow mysql] # groupadd mysql [root@airflow mysql] # useradd-r-s / sbin/nologin-g mysql mysql-d / usr/local/mysql/

# useradd-r parameter indicates that the mysql user is a system user and cannot be used to log in to the system 4 or change the permission of the mysql directory. It used to be root permission, but now it is set to mysql permission.

Chown-R mysql:mysql / usr/local/mysql/

5 、

Initialize the database

. / bin/mysql_install_db-- user=mysql-- basedir=/usr/local/mysql/-- datadir=/usr/local/mysql/data/

6 、

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, the / etc/my.cnf file is edited directly (you can also upload my-default.cnf)

Vi my.cnf [mysqld] basedir=/usr/local/mysqldatadir=/usr/local/mysql/datasocket=/tmp/mysql.sockuser=mysqlport=3306character-set-server = utf8mb4collation-server = utf8mb4_unicode_ciinit_connect='SET NAMES utf8mb4'symbolic-links=0max_connections=200default-storage-engine=INNODBlower_case_table_names=1max_allowed_packet=32Mexplicit_defaults_for_timestamp= truth [mysqld _ safe] log-error=/var/log/mysql/mysql.logpid-file=/var/run/mysql/mysql.pid

Note: mysql connection to localhost is usually done through a Unix domain socket file, usually / tmp/mysql.sock. Do not modify this socket path, otherwise an error will be returned when connecting to the local mysql: ERROR 2002 (HY000): Can't connect to local MySQL server through socket'/ tmp/mysql.sock'

Because 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 mysql users full permissions (chmod)

Chmod-R 777 / var/log/mysql/chmod-R 777 / var/run/mysql/

Otherwise, the startup will report an error, as shown in the following figure

8 、

Start the mysql service

Service mysqld start

9 、

Check the initial password and try to log in to mysql

Cat / root/.mysql_secret

10 、

Login succeeded, change the password

SET PASSWORD FOR 'root'@localhost=PASSWORD (' 123456')

11 、

Configure the mysql environment variable, modify the / etc/profile file, add the configuration at the bottom, and add self-boot.

Vi / etc/profile

Add the following configuration:

Export PATH=$PATH:/usr/local/mysql/bin

Effective immediately

Source / etc/profile

12. Boot configuration

Chmod + x / etc/init.d/mysqldchkconfig-- add mysqldchkconfig-- list

If you see the service of mysql, and if all of them are on, then you will succeed. If it is off, type

Chkconfig-level 345 mysqld on

Then restart the computer.

Reboot

View mysql running status

Service mysqld status

13 、

Allow root account IP login

Mysql-u root-puse mysql;update user set host ='% 'where user =' root';FLUSH PRIVILEGES

Profile case

[mysqld] socket=/var/lib/mysql/mysql.sockport = 3306basedir=/softwares/mysql_5727datadir=/softwares/mysql_5727/datamax_connections=200character-set-server=utf8mb4default-storage-engine=INNODBlower_case_table_names=1max_allowed_packet=32Mexplicit_defaults_for_timestamp=true

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report