EverKB

Knowledge Base Ever

Installer MySQL8 og konfiguration af brugerrettigheder på CentOS7

2019-11-15 11:37:53

tag: CentOS, MySQL, CentOS7, MySQL8, mysql_native_password, caching_sha2_password,INDENTIFIED BY, Installer MySQL, installer MySQL8, MySQL tilladelser, MySQL8 tilladelser

Vim rediger filen /etc/yum.repos.d/mysql-community.repo og gem følgende

[mysql80-community]
name=MySQL 8.0 Community Server
baseurl=http://repo.mysql.com/yum/mysql-8.0-community/el/7/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

Installer MySQL8

yum -y install mysql-community-server

Administrer MySQL med systemd

mkdir /etc/systemd/system/mysqld.service.d
cd /etc/systemd/system/mysqld.service.d
vim override.conf

Indholdet er som følger, gem filen:

[Service]
PIDFile=/var/run/mysqld/mysqld-custom.pid
ExecStart=
ExecStart=/usr/sbin/mysqld --pid-file=/var/run/mysqld/mysqld-custom.pid $MYSQLD_OPTS

Indstil MySQL-serveren til at køre automatisk og start tjenesten.

systemctl daemon-reload
systemctl enable mysqld
systemctl start mysqld

Kontroller rodbrugerens oprindelige adgangskode, og ændre adgangskoden, når du er logget ind.

Kat /var/log/mysqld.log

[root @ carbon ~] # mysql -u rod -p
Skriv 'hjælp;' eller '\ h' for hjælp. Skriv '\ c' for at rydde den aktuelle input-sætning.

Mysql> BRUG mysql;
Læsning af tabeloplysninger til færdiggørelse af tabel- og kolonnenavne
Du kan slå denne funktion fra for at få en hurtigere opstart med -A

Databasen ændret
Mysql> VÆLG bruger, vært FRA bruger;
+ ------------------ + ----------- +
| bruger | vært |
+ ------------------ + ----------- +
| mysql.infoschema | localhost |
| mysql.session | localhost |
| mysql.sys | localhost |
| rod | localhost |
+ ------------------ + ----------- +
5 rækker i sæt (0,00 sek)

Mysql> SET global validate_password.policy = 0;
Mysql> ALTER USER 'root' @ '%' IDENTIFICERET AF 'PASSWORD'

Autoriser root-brugerens fjernadgang

Opret BRUGER 'root' @ '%' INDENTIFICERET AF 'admin';
ALTER BRUGER 'root' @ '%' IDENTIFICERET AF 'admin';
FLUSH PRIVILEGES;

Opret nye brugere og autoriser adgang

Opret DATABASE-test;
Opret BRUGER 'mysql' @ '%' INDENTIFIERET AF 'admin';
Opret BRUGER 'mysql' @ 'localhost' INDENTIFICERET AF 'admin';
FLUSH PRIVILEGES;

Indstil metode til bekræftelse af adgangskode

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'admin';
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'admin';
ALTER USER 'mysql'@'localhost' IDENTIFIED WITH mysql_native_password BY 'admin';
ALTER USER 'mysql'@'%' IDENTIFIED WITH mysql_native_password BY 'admin';
FLUSH PRIVILEGES;

Eller ved at ændre konfigurationsfilen: mysql_native_password i /etc/my.cnf

[mysqld]
default_authentication_plugin=mysql_native_password

tag

CentOS7 CentOS PHP Linux Python3 Python MySQL MariaDB YUM JavaScript CSS Redis MySQL8 caching_sha2_password HTML mysql_native_password PHP7 date add IntelliJIDEA PEAR SOCKS5 Proxy Server WebStorm Chrome find remi Tag Apache du jQuery PHP5.5 src cURL hide nginx Shadowsocks-Python V2Ray availability eth0 MariaDB10.4 PostgreSQL sub folder date Install MongoDB pdo_sqlsrv SOCKS5 Web Server File Upload mssql-tools register_shutdown_function Symfony ADDDATE DevExpress JetBrain php-fpm sqlsrv Zend Framework height network interface Shadowsocks-Libev unixODBC-devel Aura error_get_last Port 80 string data INDENTIFIED BY password policy requirements SOCKS Web Development Fedora Media Writer msodbcsql Redis5 SVN absolute Deepin jemalloc SQLAlchemy convert FuelPHP mysqlclient Shadowsocks toggle at-symbol Error Control Operator margin PHPUnit Framework ss5.passwd daemon process IIS password SOCKET vps center Fatal Errors MongoDB4 sudoers .htaccess DATE_SUB Phalcon SQL Server 2017 WiFi Compiling PHP frequency conflict set_error_handler TestCase apr Elasticsearch7.3 PHPUnit ss5.conf daemon HTTP particles.js Slim Vincent Garreau Failed to build these modules: _uuid MongoDB Sudo DATE_ADD ip command pg_bha.conf SQL Server width Compiling Apache Frameworks MySQL-python scrollbar Tcp BBR Apache2.4 Elasticsearch libpython3.7m.so.1.0 PHPStorm ss5-3.8.9 CURLOPT_POSTFIELDS NodeJs show VIM Bluetooth Failed to build these modules: _ctypes Minimal ISO substr date sub INTERVAL PECL SQL Date Funcitons Wi-Fi CodeIgniter font-size root Tag Cloud apache httpd dual network interfaces Laravel ss5 CURLFille horiz-align node.js ShadowsocksR vertical-align BarManager exec mb_substr PyCharm SUBDATE