当前位置:网站首页>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.
边栏推荐
- Jvm: thread context classloader
- Wechat applet - a case of comparing the size of numbers
- Niuke monthly race 14- simple counting
- Huawei intermodal game or application review rejected: the application detected payment servicecatalog:x6
- 颠倒字符串中的单词(split、双端队列)
- 如何为Excel中的单元格自动填充颜色
- pca从0到1
- State Administration of market supervision and state Internet Information Office: carry out data security management certification
- LeetCode Algorithm 1791. Find the central node of the star chart
- Bracket generation (backtracking)
猜你喜欢

初探性能优化!从2个月到4小时的性能提升!

Software engineering - system flow chart

Annotate your own point cloud dataset with labelcloud open source tool as a tutorial of Kitti annotation format (support PCD and bin point clouds)
![MySQL training report [with source code]](/img/c2/46bdc2f8c522d2c8881e532b6f3f49.png)
MySQL training report [with source code]

如何最大化的利用各种匹配方式? ——Google SEM

Entity class dto to VO is converted through plug-in

Why should a redis cluster use a reverse proxy? Just read this one

Wechat applet - a case of comparing the size of numbers

MySQL实训报告【带源码】

kmeans从0到1
随机推荐
2022 blind box applet app has become a new drainage outlet for enterprises
"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
LeetCode Algorithm 1791. Find the central node of the star chart
Watermelon video synchronization Tiktok also has benefits ~ the official "China Video Partner Program"
广泛匹配修饰符符号已经被弃用,请勿使用
php安全开发 12博客系统的 系统模块信息的修改
[从零开始学习FPGA编程-20]:快速入门篇 - 操作步骤4-2-Altera Quartus II工具的快速使用(modelSim联合仿真、程序下载到Altera开发板)
Quatre schémas de mise en file d'attente des messages pour redis
I'm fired because I can only test basic functions····
Simulated 100 questions and simulated examination for safety management personnel of metal and nonmetal mines (small open pit quarries) in 2022
博文推荐|BookKeeper - Apache Pulsar 高可用 / 强一致 / 低延迟的存储实现
Data system provider Jidao technology joins dragon lizard community
Why should a redis cluster use a reverse proxy? Just read this one
Point cloud perception algorithm interview knowledge points (II)
Chinese Version Vocaloid AI Tuner Feasibility Test
The role of MOV ah, 4CH int 21
MP3 to Wav to Midi
redis集群(cluster)+哨兵模式+主从(replicas)
Tabulation v.s. Recursion With Memory (Dynamic Programming)
如何定位关键词使得广告精准投放。