当前位置:网站首页>Linux (centos7) installer mysql - 5.7
Linux (centos7) installer mysql - 5.7
2022-06-12 01:44:00 【Je l'ai testé en premier.】
1. Télécharger à partir du site officielmysql-5.7.14-linux-glibc2.5-x86_64.tar.gzSite officiel: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. CréationmysqlGroupe d'utilisateurs pour/Utilisateurs, dataRépertoires et leurs répertoires d'utilisateurs
# groupadd mysql
# useradd -r -g mysql mysql
# mkdir -p /data/mysqldb
3. Décompresser le paquet d'installation et copier le contenu du paquet décompresser à mysqlRépertoire d'installation pour/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 CréationmysqlRépertoire d'installation, Vous pouvez décompresser mysql-5.7.14-linux-glibc2.5-x86_64 Déplacer les fichiers sous le dossier dans le répertoire
4. InitialisationmysqlBase de donnéescd /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.7Nouvelles caractéristiques:Comme vous pouvez le voir ci - dessus,mysql_install_db Il n'est plus recommandé ,Il est proposé de modifier comme suit:mysqld --initialize Initialisation complète de l'Instance .
\# ./bin/mysqld --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysqldb --initialize
Utilisez plutôt mysqld --initialize Après,Si datadir Il y a déjà des fichiers de données dans le Répertoire de destination pointé , L'invite suivante apparaît:
\# ./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
D'après ce qui précède,, On doit vidermysqlDedataTable des matières, Exécuter la commande de vidange comme suit :
\# cd /data/mysqldb# rm -fr \*
Puis rediriger la commande d'initialisation comme suit :
[[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
Rappelez - vous le mot de passe aléatoire ci - dessus , Comme ci - dessus**mjT,#x_5sW, Voici ce que nous devons utiliser pour modifier le mot de passe .
5. Vérifier si le démarrage est possible sous mysqlServices
# 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). #Pas passé.cmake Edited , L'initialisation de la base de données échouera ;
Solutions:vim support-files/mysql.server Désignationdatadir=/data/mysqldb basedir=/usr/local/mysql
Starting MySQL… SUCCESS!
Si c'est le cas, /usr/local/mysqlPourmysqlRépertoire d'installation pourbasedir, L'erreur suivante se produit lors du démarrage du 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)
D'en haut.mysqlDetar.gz Le répertoire d'installation par défaut pour le paquet d'installation est /usr/local/mysql, À ce stade, nous devons modifier/support-files/mysql.serverDocumentbasedirEtdatadir Le chemin du Répertoire est celui où se trouve notre environnement mysqlDebasedirEtdatadirChemin, Comme suit:
- [[email protected] ]
- # vim support-files/mysql.server
- --------------------------
- …
- basedir=/usr/local/mysql
- datadir=/data/mysqldb
- …
- --------------------------
- # ./support-files/mysql.server start
- Starting MySQL… SUCCESS!
6. Créer un lien souple
\# ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql
7. Créer un profil
Sera généré par défaut my.cnfSauvegarde
\# mv /etc/my.cnf /etc/my.cnf.bak
Entréemysql Le répertoire d'installation pour prend en charge les répertoires de fichiers
\# cd /usr/local/mysql/support-files
Le modèle de profil de copie est nouveau mysqlProfil,
\# cp my-default.cnf /etc/my.cnf
De nouvelles options de profil peuvent être modifiées au besoin , Ne modifiez pas les options de configuration , mysqlExécuter comme paramètre de configuration par défaut.
Voici mes modifications de profil /etc/my.cnf, Définir le code àutf8Pour éviter les codes.
\# vim /etc/my.cnf\[mysqld\]basedir = /usr/local/mysqldatadir = /data/mysqldbcharacter\_set\_server=utf8init\_connect='SET NAMES utf8'\[client\]default-character-set=utf8
8. ConfigurationmysqlDémarrage automatique du service
Copier le fichier de démarrage à /etc/init.d/ La commande rejouer est mysqld
\# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
Augmenter les permissions d'exécution
\# chmod 755 /etc/init.d/mysqld
Vérifiez qu'il n'y a pas de mysqldC'est,Ajouter si nonmysqld:
\# chkconfig --list mysqld# chkconfig --add mysqld
ParamètresMySQLIn345Démarrage automatique du niveau
\# chkconfig --level 345 mysqld on
Ou utilisez cette commande pour démarrer :
\# chkconfig mysqld on
9. mysqlDémarrage du Service/Redémarrer/Arrêtez!
DémarragemysqlServices
\# service mysqld start
RedémarrermysqlServices
\# service mysqld restart
Arrêtez!mysqlServices
\# service mysqld stop
Vous pouvez d'abord supprimer ou annoter la phrase la plus basse du fichier :sql\_mode=NO\_ENGINE\_SUBSTITUTION,STRICT\_TRANS\_TABLES
10. InitialisationmysqlUtilisateursrootMot de passe pour
D'abord.mysqlArrêt du Service
\# service mysqld stop
EntréemysqlRépertoire d'installation, Mise en œuvre:
# 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
Ouvrir un autre terminal(p.s. Si ouissh Connectez - vous à , Créer un autresshConnectez - vous), Faites ce qui suit:
# mysql -u root mysql# En exécutant cette phrase , Il faut d'abord exécuter la phrase précédente :./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.7Nouvelles caractéristiques,UsersNon dans le tableaupasswordLes champs sont là.,authentication_string C'estpassword
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
Ici, Après la mise en placemysqlUtilisateursroot Et assurez - vous que mysqlL'ensemble d'encodage estutf8, Attention!,Nouvelle versionmysql.user Le champ mot de passe dans le tableau est authentication\_string
Raccourcis clavierctrl + cArrêtez!# ./bin/mysqld\_safe ...Les ordres, RedémarrermysqlServices, Connectez - vous avec un nouveau mot de passemysql:
# 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
Hé!? Je dois changer le Code , Nous passonsmysqladminPour modifier le mot de passe, Saisissez d'abord le mot de passe original est le nouveau mot de passe que vous avez modifié à l'étape précédente root, Réinitialiser le nouveau mot de passe !!!
# cd /usr/local/mysql
# ./bin/mysqladmin -u root -p password
#C'estpasswordC'est le paramètre, Ce n'est pas pour root La valeur du mot de passe 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>
Ou directement:
# ./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.
Parmi eux,g!#l4:6+rMnTC'est que nous utilisonsmysqld --initialize Gardez à l'esprit les mots de passe aléatoires
11. mysqlAutorisation à distance
Le format est le suivant::
mysql> grant all \[privileges\] on db\_name.table\_name to 'username'@'host' identified by 'yourpassword';
Voici quelques exemples:
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)
Ou
mysql> grant all on \*.\* to 'root'@'%' identified by 'root';
Ici, C'est fait.mysqlInstallation Et la configuration!!!
Note::EnfinwindowsAccès à distancelinux-mysqlLa connexion a échoué, Pas de port ouvert 3306:Résolution:iptables -I INPUT -p tcp --dport 3306 -j ACCEPT
Installation vérifiée MySQL5.7Pas besoin.cmake.
边栏推荐
- Pyinstaller packaging Exe (detailed tutorial)
- UoE UG2 Inf Course Research
- Redis集群更换节点IP后如何恢复集群并保留完整集群数据
- Loop loop and CX
- 如何让杀毒软件停止屏蔽某个网页?以GDATA为例
- Don't write about the full screen explosion, try the decorator mode, this is the elegant way!!
- Data in the assembly cannot start with a letter! 0 before the beginning of a letter
- [project training] wechat official account to obtain user openid
- [从零开始学习FPGA编程-19]:快速入门篇 - 操作步骤4-1- Verilog 软件下载与开发环境的搭建- Altera Quartus II版本
- Point cloud perception algorithm interview knowledge points (I)
猜你喜欢

Various error reporting solutions encountered by Kali during Empire installation

为什么我们要使用谷歌搜索广告?

The CSV used for JMeter performance test is bullshit

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

聯調這夜,我把同事打了...

Google Ads 竞价的运作机制

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!

PyGame alien invasion

Ce soir - là, j'ai battu mon collègue...

Weekly CTF week 1: Amazing tapes
随机推荐
Redis cluster + sentinel mode + replicas
[project training] JWT
php安全开发 13博客系统的栏目模块的编写
php开发 博客系统的公告模块的建立和引入
Common assertions for JMeter interface testing
Software engineering course: Chapter 2 software problem definition and feasibility analysis after class exercises
华为联运游戏或应用审核驳回:应用检测到支付serviceCatalog:X6
MP3 to Wav to Midi
JSON conversion: entity classes and jsonobject are converted to each other, and list and jsonarray are converted to each other (fastjson version)
Markov networks and conditional random fields
LeetCode Algorithm 997. 找到小镇的法官
2022 blind box applet app has become a new drainage outlet for enterprises
Educational knowledge and ability test questions of primary and secondary school educational endowment examination in the second half of 2019 (middle school) - subjective questions
Concepts of programs, processes, and threads
Redis實現消息隊列的4種方案
State Administration of market supervision and state Internet Information Office: carry out data security management certification
Software engineering - system flow chart
[project training] verification notes
Unit tests in golang
2022工具钳工(高级)复训题库及在线模拟考试题库来源:安全生产模拟考试一点通公众号