当前位置:网站首页>Installing mysql-5.7 for Linux (centos7)
Installing mysql-5.7 for Linux (centos7)
2022-06-12 01:45:00 【I tested it first】
1. Download from official website mysql-5.7.14-linux-glibc2.5-x86_64.tar.gz Official website :http://dev.mysql.com/downloads/mysql/
# wget -chttp://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.14-linux-glibc2.5-x86_64.tar.gz
2. establish mysql User group / user , data Directory and its user directory
# groupadd mysql
# useradd -r -g mysql mysql
# mkdir -p /data/mysqldb
3. Unzip the installation package and copy the contents of the unzipped package to mysql Installation directory /home/mysql
# tar -xzvf mysql-5.7.14-linux-glibc2.5-x86_64.tar.gz
# cd mysql-5.7.14-linux-glibc2.5-x86_64
# mv * /usr/local/mysql
# mkdir -p /usr/local/mysql establish mysql The installation directory , You can decompress mysql-5.7.14-linux-glibc2.5-x86_64 Move the files under the folder to the directory
4. initialization mysql database cd /usr/local/mysql
\# ./bin/mysql\_install\_db --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysqldb
2015-11-1002:09:17 \[WARNING\] mysql\_install\_db is deprecated. Please consider switching to mysqld --initialize
2015-11-1002:09:23 \[WARNING\] The bootstrap logisn't empty:
2015-11-1002:09:23 \[WARNING\] 2015-11-10T10:09:18.114182Z 0 \[Warning\] --bootstrap is deprecated. Please consider using --initialize instead
2015-11-10T10:09:18.129343Z 0 \[Warning\] Changed limits: max\_open\_files: 1024 (requested 5000)
2015-11-10T10:09:18.129408Z 0 \[Warning\] Changed limits: table\_open\_cache: 431 (requested 2000)
p.s. : mysql5.7 New characteristics : You can see that from the top ,mysql_install_db It's no longer recommended , It is suggested to change it to mysqld --initialize Complete instance initialization .
\# ./bin/mysqld --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysqldb --initialize
change to the use of sth. mysqld --initialize after , If datadir There are already data files in the target directory pointed to , The following prompt will appear :
\# ./bin/mysqld --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysqldb --initialize
2016-04-08T01:46:53.153530Z 0 \[Warning\] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit\_defaults\_for\_timestamp server option (see documentation for more details).
2016-04-08T01:46:53.155856Z 0 \[ERROR\] --initialize specified but the data directory has files in it. Aborting.
2016-04-08T01:46:53.155879Z 0 \[ERROR\] Aborting
It can be seen from the above that , We need to empty mysql Of data Catalog , Execute the emptying command as follows :
\# cd /data/mysqldb# rm -fr \*
Then re execute the initialization command as follows :
[[email protected] /] cd /usr/local/mysql
[[email protected] mysql ] ./bin/mysqld --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysqldb --initialize
[[email protected] ]2016-04-08T01:47:57.556677Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-04-08T01:47:59.945537Z 0 [Warning] InnoDB: New logfiles created, LSN=45790
2016-04-08T01:48:00.333528Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2016-04-08T01:48:00.434908Z 0 [Warning] No existing UUID has been found, so we assume that this is thefirsttime that this server has been started. Generating anew UUID: ece26421-fd2b-11e5-a1e3-00163e001e5c.2016-04-08T01:48:00.440125Z 0 [Warning] Gtid table is not ready to be used. Table ‘mysql.gtid_executed’ cannot be opened.
2016-04-08T01:48:00.440904Z 1 [Note] A temporary password is generated for [email protected]: **mjT,#x_5sW
Remember the random password above , Above **mjT,#x_5sW, Below we need to use... When changing the password .
5. Check whether it can be started mysql service
# cd /usr/local/mysql# ./support-files/mysql.server start
Starting MySQL. ERROR! The server quit without updating PID file (/usr/local/mysql/data/localhost.localdomain.pid). # Not through cmake Edited , Initializing the database will fail ;
terms of settlement :vim support-files/mysql.server Appoint datadir=/data/mysqldb basedir=/usr/local/mysql
Starting MySQL… SUCCESS!
If used instead /usr/local/mysql by mysql Installation directory basedir, The following error will appear when starting the service :
[[email protected] mysql] #./support-files/mysql.server start
[[email protected] ]./support-files/mysql.server: line 276: cd: /usr/local/mysql: No such fileor directory
[[email protected] ] Starting MySQL ERROR! Couldn’t find MySQL server (/usr/local/mysql/bin/mysqld_safe)
From the top mysql Of tar.gz The default installation directory of the installation package is /usr/local/mysql, At this time, we need to modify /support-files/mysql.server Of documents basedir and datadir The directory path is where our environment is located mysql Of basedir and datadir route , as follows :
- [[email protected] ]
- # vim support-files/mysql.server
- --------------------------
- …
- basedir=/usr/local/mysql
- datadir=/data/mysqldb
- …
- --------------------------
- # ./support-files/mysql.server start
- Starting MySQL… SUCCESS!
6. Create soft link
\# ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql
7. create profile
Will be generated by default my.cnf Backup
\# mv /etc/my.cnf /etc/my.cnf.bak
Get into mysql The installation directory of supports file directory
\# cd /usr/local/mysql/support-files
Copy the profile template as new mysql The configuration file ,
\# cp my-default.cnf /etc/my.cnf
New profile options can be modified as needed , Do not modify the configuration options , mysql Run according to the default configuration parameters .
Here is how I modified the configuration file /etc/my.cnf, Set the code to utf8 In case of garbled code
\# vim /etc/my.cnf\[mysqld\]basedir = /usr/local/mysqldatadir = /data/mysqldbcharacter\_set\_server=utf8init\_connect='SET NAMES utf8'\[client\]default-character-set=utf8
8. To configure mysql The service starts automatically
Copy the startup file to /etc/init.d/ Give the same command as mysqld
\# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
Add execution permission
\# chmod 755 /etc/init.d/mysqld
Check that there is no... In the list of self startup items mysqld This , Add if not mysqld:
\# chkconfig --list mysqld# chkconfig --add mysqld
Set up MySQL stay 345 Level auto start
\# chkconfig --level 345 mysqld on
Or use this command to set the boot :
\# chkconfig mysqld on
9. mysql Start of service / restart / stop it
start-up mysql service
\# service mysqld start
restart mysql service
\# service mysqld restart
stop it mysql service
\# service mysqld stop
You can delete or comment out the sentence at the bottom of the file first :sql\_mode=NO\_ENGINE\_SUBSTITUTION,STRICT\_TRANS\_TABLES
10. initialization mysql user root Password
First the mysql Service stopped
\# service mysqld stop
Get into mysql The installation directory , perform :
# cd /usr/local/mysql
# ./bin/mysqld_safe --skip-grant-tables --skip-networking&
[1] 6225
[[email protected] mysql]# 151110 02:46:08 mysqld_safe Logging to ‘/data/mysqldb/localhost.localdomain.err’.151110 02:46:08 mysqld_safe Starting mysqld daemon with databases from /data/mysqldb
Open another terminal (p.s. If it is ssh Connect logged in , Create another ssh Connect to ), Perform the following operations :
# mysql -u root mysql# When running this sentence , You need to execute the previous sentence first :./bin/mysqld_safe
Reading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -A********************************************************************Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.
mysql> use mysql;Database changed
mysql> UPDATE user SET password=PASSWORD(‘root’) WHERE user=‘root’;ERROR 1054 (42S22): Unknown column ‘password’ in ‘field list’
mysql> update user set authentication_string = PASSWORD(‘root’) where user = ‘root’;
Query OK, 1 row affected, 1 warning (0.02 sec)Rows matched: 1 Changed: 1 Warnings: 1
#MySQL5.7 New characteristics ,Users Not in the table password Field ,authentication_string Namely password
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> \s--------------mysql Ver 14.14 Distrib 5.7.9, for linux-glibc2.5 (x86_64) using EditLine wrapperConnection id: 2Current database: mysqlCurrent user: [email protected]: Not in useCurrent pager: stdoutUsing outfile: ''Using delimiter: ;Server version: 5.7.9 MySQL Community Server (GPL)Protocol version: 10Connection: Localhost via UNIX socketServer characterset: utf8Db characterset: utf8Client characterset: utf8Conn. characterset: utf8UNIX socket: /tmp/mysql.sockUptime: 4 min 47 secThreads: 1 Questions: 43 Slow queries: 0 Opens: 127 Flush tables: 1 Open tables: 122 Queries per second avg: 0.149--------------
mysql> exit;Bye
Here we are , Set the mysql user root And ensure that mysql The code set is utf8, Note that the above , The new version of the mysql.user The password field in the table is authentication\_string
Shortcut key ctrl + c stop it # ./bin/mysqld\_safe ... command , Restart mysql service , Connect with a new password mysql:
# service mysqld startStarting MySQL SUCCESS!
[[email protected] bin]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 3Server version: 5.7.9************************************************************************Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.
mysql> use mysql;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql > exit;Bye
Why ? Ask me to change my password , We go through mysqladmin To change the password , Enter the original password first, which is the new password modified in the above steps root, Then set a new password !!!
# cd /usr/local/mysql
# ./bin/mysqladmin -u root -p password
# This password Is the parameter , Not to be set to root Value of password Enter password: New password:
Confirm new password:
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.# mysql -uroot -pEnter password: Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 6Server version: 5.7.9 MySQL Community Server (GPL)Copyright 2000, 2015, Oracle and/or its affiliates. All rights reserved.******************************************************************************Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.mysql> use mysql;Reading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -ADatabase changedmysql>
Or directly :
# ./bin/mysqladmin -uroot -p’g!#l4:6+rMnT’ password ‘root’
mysqladmin: [Warning] Using a password on the command line interface can be insecure.Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.
among ,g!#l4:6+rMnT That's what we're using mysqld --initialize Remember the random password
11. mysql Remote authorization
The format is as follows :
mysql> grant all \[privileges\] on db\_name.table\_name to 'username'@'host' identified by 'yourpassword';
Examples are as follows :
mysql> `grant` all privileges on \*.\* to 'root'@'%' identified by 'root';
Query OK, 0 rows affected, 1 warning (0.04 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
Or use
mysql> grant all on \*.\* to 'root'@'%' identified by 'root';
Here we are , It's done mysql Installation And configuration !!!
notes : Last windows The remote access linux-mysql The connection fails , There are no open ports 3306: solve :iptables -I INPUT -p tcp --dport 3306 -j ACCEPT
Verified installation MySQL5.7 Unwanted cmake.
边栏推荐
- Four schemes for redis to implement message queue
- Operation of simulated examination platform of diazotization process examination question bank in 2022
- [C language] C language file operation | C language file reading and writing | single character reading and writing | string reading and writing | format reading and writing | binary form reading and
- Tiobe - programming language ranking in June 2022
- In 2022, the internal promotion of the "MIHA Tour" golden, silver and silver social recruitment started in April and march! Less overtime, good welfare, 200+ posts for you to choose, come and see!
- 马尔可夫网络 与 条件随机场
- Three times a day (in serial...)
- Basic use of MATLAB
- Simplified interpretation of accuracy and recall in AI papers
- PCA from 0 to 1
猜你喜欢

Program environment and pretreatment

【项目实训】校验注解

Weekly CTF week 1: Amazing tapes

I'm fired because I can only test basic functions····

kmeans从0到1

Huawei intermodal game or application review rejected: the application detected payment servicecatalog:x6

On the night of the joint commissioning, I beat up my colleagues

Several visualization methods of point cloud 3D object detection results (second, pointpillars, pointrcnn)

西南林业大学“西林链”通过工信部电子标准院功能测试 | FISCO BCOS案例

Blog recommended | bookkeeper - Apache pulsar high availability / strong consistency / low latency storage implementation
随机推荐
Concepts of programs, processes, and threads
Comprehensive quality of teaching resources in the second half of 2019 - subjective questions
kali安装empire过程中遇到的各种报错解决方案
【项目实训】微信公众号获取用户openid
[project training] wechat official account template message push
Design practice of rongyun Im on electron platform
Google 搜索广告系列设置前有哪些准备工作?
Unity顶点动画的阴影实现
Huawei intermodal game or application review rejected: the application detected payment servicecatalog:x6
Machines / scenarios not suitable for webrdp
Program environment and pretreatment
华为联运游戏或应用审核驳回:应用检测到支付serviceCatalog:X6
Applets 111111
Go language learning summary (7) -- Dachang go programming specification summary
"Xilin chain" of Southwest Forestry University passed the functional test of Electronic Standards Institute of the Ministry of industry and information technology | FISCO bcos case
Simplified interpretation of accuracy and recall in AI papers
LeetCode LCP 07. 传递信息
[project training] JWT
“還是學一門技術更保險!”杭州校區小哥哥轉行軟件測試,喜提10K+雙休!
[从零开始学习FPGA编程-20]:快速入门篇 - 操作步骤4-2-Altera Quartus II工具的快速使用(modelSim联合仿真、程序下载到Altera开发板)