sql >> Database >  >> RDS >> Mysql

MySQL 8 instellen vanuit Binary Tarball

In dit artikel bespreken we de binaire tarball MySQL-installatie. We zullen de installatie van MySQL 8 bespreken met behulp van binaire tarballs en MySQL 8 op CentOS 7 installeren met behulp van binaire tarballs. Installatie op basis van binaire tarballs heeft zijn eigen voor- en nadelen, we zullen dat bespreken. Installatie vanuit binaire tarballs is onafhankelijk van de Linux-distributie of het init-systeem dat de distributie gebruikt. Dit betekent dat dezelfde installatiemethode bijvoorbeeld werkt op RPM en op dead-based systemen, maar ook op meer exotische distributies zoals Gen 2. Er is ook een binaire tarball voor macOS beschikbaar en de installatieprocedure is niet veel anders, deze methode heeft een meer handmatig woord nodig. Het mysql_install_db-script is verouderd in MySQL 5.7 en is verwijderd uit MySQL 8. De eerste database-creatie kan worden gedaan met de opdracht mysqld –initialize. Nu we MySQL handmatig gaan installeren, gebruiken we de opdracht mysqld –initialize om een ​​lege database te maken.

Laten we eerst wat opruimen. We zullen de zeer oude versie van mariadb-libs verwijderen die my.cnf levert, wat in strijd zou zijn met de onze.

Verwijder Mariadb-bibliotheken:

[[email protected] ~]# sudo yum remove -y mariadb-libs

Download de bron-tarball van MySQL-gemeenschapsenquête 8.0

[[email protected] ~]# curl -L -O https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.11-linux-glibc2.12-x86_64.tar.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- 0:00:01 --:--:-- 0
100 575M 100 575M 0 0 7726k 0 0:01:16 0:01:16 --:--:-- 8516k
[[email protected] ~]# ll
-rw-r--r--. 1 root root 603019898 Jul 23 10:31 mysql-8.0.11-linux-glibc2.12-x86_64.tar.gz

De tarball is niet gedownload, dus laten we hem uitpakken naar usr/local

[[email protected] ~]# sudo tar xvfz mysql-8.0.11-linux-glibc2.12-x86_64.tar.gz -C /usr/local/

De pre-reqs invullen

laten we libaio installeren.

[[email protected] ~]# sudo yum -y install libaio
Create a MySQL group, this is normally done by the packages but because we are installing it manually from binary tarball now we need to do it.
[[email protected] ~]# sudo groupadd mysql

Laten we een MySQL-gebruiker maken die u

[[email protected] ~]# sudo useradd -r -g mysql -s /bin/false mysql

controleer of de mysql-gebruiker aanwezig is

[[email protected] ~]# getent passwd | grep mysql
mysql:x:988:1001::/home/mysql:/bin/false

heb /usr/local en maak een symbolische link en vink deze vervolgens aan

[[email protected] ~]# cd /usr/local
[[email protected] local]# sudo ln -s mysql-8.0.11-linux-glibc2.12-x86_64 mysql
[[email protected] local]# ls -la mysql
lrwxrwxrwx. 1 root root 35 Jul 23 15:08 mysql -> mysql-8.0.11-linux-glibc2.12-x86_64

maak een MySQL-bestandenmap die het eigendom en de rechten van de dataset zal bevatten terwijl u zich in /usr/local/

bevindt
[[email protected] local]# sudo mkdir mysql-files
[[email protected] local]# sudo chown mysql:mysql mysql-files
[[email protected] local]# sudo chmod 750 mysql-files

Initialiseer MySQL

Ga naar mysql directory en initialiseer mysqld, in eerdere versies heette dit mysql_installed_db

[[email protected] local]# cd mysql
[[email protected] mysql]# sudo ./bin/mysqld --initialize --user=mysql
2020-07-23T12:12:10.028247Z 0 [System] [MY-013169] [Server] /usr/local/mysql-8.0.11-linux-glibc2.12-x86_64/bin/mysqld (mysqld 8.0.11) initializing of server in progress as process 25014
2020-07-23T12:12:15.470538Z 5 [Note] [MY-010454] [Server] A temporary password is generated for [email protected]: Hqn+jK6lfzNS
2020-07-23T12:12:18.875370Z 0 [System] [MY-013170] [Server] /usr/local/mysql-8.0.11-linux-glibc2.12-x86_64/bin/mysqld (mysqld 8.0.11) initializing of server has completed

Merk op dat het tijdelijke root-wachtwoord wordt gegenereerd, wat in mijn geval is ([email protected]:Hqn+jK6lfzNS)

Kopieer het init-script van ondersteuningsbestanden naar /etc/init.d

[[email protected] mysql]# sudo cp ./support-files/mysql.server /etc/init.d/

start mysql-server met init-bestand dat we zojuist hebben gekopieerd

[[email protected] mysql]# sudo /etc/init.d/mysql.server start
Starting MySQL.Logging to '/usr/local/mysql/data/localhost.localdomain.err'.
. SUCCESS!

Verbind nu ro mysql door het eerder gegenereerde tijdelijke wachtwoord op te geven

[[email protected] mysql]# ./bin/mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.11
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>

Laten we het tijdelijke wachtwoord voor de rootgebruiker wijzigen.

mysql> alter user 'root'@'localhost' identified by 'My_root_pass1!';
Query OK, 0 rows affected (0.07 sec)

Controleer de locatie van het socketbestand:

mysql> show variables like 'socket';
+---------------+-----------------+
| Variable_name | Value |
+---------------+-----------------+
| socket | /tmp/mysql.sock |
+---------------+-----------------+
1 row in set (0.01 sec)

Om te voorkomen dat u altijd de padnaam van clientprogramma's moet typen wanneer u met MySQL werkt, kunt u de directory /usr/local/mysql/bin aan uw PATH-variabele toevoegen:

[[email protected] mysql]# export PATH=$PATH:/usr/local/mysql/bin
[[email protected] mysql]# ps -ef | grep mysql
root 25130 1 0 15:16 pts/1 00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/usr/local/mysql/data --pid-file=/usr/local/mysql/data/localhost.localdomain.pid
mysql 25215 25130 1 15:16 pts/1 00:00:42 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=localhost.localdomain.err --pid-file=/usr/local/mysql/data/localhost.localdomain.pid
root 26171 21375 0 16:21 pts/1 00:00:00 mysql -uroot -px xxxxxxxxxxxx
root 26191 25365 0 16:23 pts/2 00:00:00 grep --color=auto mysq

  1. Hoe MySQL op CentOS 6 te installeren

  2. MySQL-export naar outfile:CSV escape-tekens

  3. Het totale aantal seconden extraheren uit een intervalgegevenstype

  4. Hoe kan ik een enkele opdracht vanaf de opdrachtregel via sql plus geven?