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

Mysql5.7 single instance installation (binary)

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

Share

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

1. Download the binary installation package

Mysql-5.7.21-linux-glibc2.12-x86_64.tar.gz

Tar-xvf mysql-5.7.21-linux-glibc2.12-x86_64.tar.gz

two。 Copy the installation package and configuration files (if there are no special circumstances, unpack the installation package and place it in this directory)

Cp-rf mysql / usr/local/mysql

Cp-rf my5.7.cnf / etc/my.cnf

3. Create a mysql user

Useradd mysql

4. Add data catalog

Mkdir-p / home/mysql3306/mysql3306

Mkdir-p / home/mysql3306/logs

5. Modify directory permissions

Chown mysql:mysql-R / home/mysql3306

6. Modify the configuration file

Socket = / tmp/mysql.sock (location of the socket file)

Datadir = / home/mysql3306/mysql3306 (data file storage directory)

Server-id = 12023306 (set serverid naming rules: the last two digits of ip + port number)

Port = 3306 (boot port)

Innodb_buffer_pool_size = 1024m (innodb buffer pool size)

* if the single instance of the core node is configured to account for about 75% of the total memory of the system, if it is not the core node, it will be set according to the specific business pressure.

7. Initialize the database (confirm 2 OK)

/ usr/local/mysql/bin/mysqld-defaults-file=/etc/my.cnf-initialize-basedir=/usr/local/mysql-datadir=/home/mysql3306/mysql3306-user=mysql

-- set random passwords automatically after initialize initialization

-- initialize-insecure initialization does not assign random passwords

-- basedir=/usr/local/mysql mysql installation directory

-- datadir=/home/mysql3306/mysql3306 mysql data directory

Look for the initial password in mysql-error.log

2018-03-13T07:18:45.762441+08:00 1 [Note] A temporary password is generated for root@localhost: W2O?kK-g#:y7

8. Start mysql5.7

Click (here) to collapse or open

# / usr/local/mysql/bin/mysqld_safe-- defaults-file=/etc/my.cnf-- user=mysql & [2] 2478 [root@mysql5 logs] # 2018-03-12T23:23:23.847910Z mysqld_safe Logging to'/ home/mysql3306/logs/mysql-error.log'.2018-03-12T23:23:23.886684Z mysqld_safe Starting mysqld daemon with databases from / home/mysql3306/mysql33069. Enter mysql5.7

# / usr/local/mysql/bin/mysql-S / tmp/mysql3306.sock-p

Initialize password

Click (here) to collapse or open

Mysql > show databases;ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.mysql > set password=password ('root')->; Query OK, 0 rows affected, 1 warning (0.00 sec) mysql > flush privileges;Query OK, 0 rows affected (0.02 sec)

10. Configure environment variables

Vi / etc/profile

Export MYSQL_HOME=/usr/local/mysql

PATH=$PATH:$MYSQL_HOME/bin

If the system comes with an earlier version of mysql, the following occurs without pointing to the predetermined path:

[root@mysql5 logs] # which mysql

/ usr/bin/mysql

Delete the previous version of mysql

Yum-y remove mysql*

Source / etc/profile

Or

Rm-rf / usr/bin/mysql*

Ln-s / usr/local/mysql/bin/mysql / usr/bin/mysql

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