In a web browser, visit:
https://dev.mysql.com/downloads/repo/yum/
1 |
wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm |
Now that we’ve verified that the file wasn’t corrupted or changed, we’ll install the package:
1 |
sudo rpm -ivh mysql57-community-release-el7-9.noarch.rpm |
This adds two new MySQL yum repositories, and we can now use them to install MySQL server:
1 |
yum install mysql-server |
We’ll start the daemon with the following command:
1 |
sudo systemctl start mysqld |
systemctl
doesn’t display the outcome of all service management commands, so to be sure we succeeded, we’ll use the following command:
1 |
sudo systemctl status mysqld |
If MySQL has successfully started, the output should contain Active: active (running)
and the final line should look something like:
- Dec 01 19:02:20 centos-512mb-sfo2-02 systemd[1]: Started MySQL Server.
During the installation process, a temporary password is generated for the MySQL root user. Locate it in the mysqld.log
with this command:
1 |
grep 'temporary password' /var/log/mysqld.log |
Make note of the password, which you will need in the next step to secure the installation and where you will be forced to change it. The default password policy requires 12 characters, with at least one uppercase letter, one lowercase letter, one number and one special character.
Step 3 — Configuring MySQL
MySQL includes a security script to change some of the less secure default options for things like remote root logins and sample users.
Use this command to run the security script.
1 |
mysql_secure_installation |
Выполните следующие шаги :
- [Y] — Установите пароль для пользователя root;
- [Y] — Удалите анонимных пользователей;
- [Y] — Запретите удаленное подключение пользователю root;
- [Y] — Удалите тестовую базу данных и запретите доступ к ней;
- [Y] — Перезагрузите таблице привилегий.
Авто логин в mysql консоль в /etc/my.cnf добавить:
1 2 3 |
[client] user = root password = ***** |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
mysql> status; -------------- mysql Ver 14.14 Distrib 5.7.17, for Linux (x86_64) using EditLine wrapper Connection id: 3 Current database: Current user: root@localhost SSL: Not in use Current pager: stdout Using outfile: '' Using delimiter: ; Server version: 5.7.17 MySQL Community Server (GPL) Protocol version: 10 Connection: Localhost via UNIX socket Server characterset: latin1 Db characterset: latin1 Client characterset: latin1 Conn. characterset: latin1 UNIX socket: /var/lib/mysql/mysql.sock Uptime: 13 sec Threads: 1 Questions: 6 Slow queries: 0 Opens: 105 Flush tables: 1 Open tables: 98 Queries per second avg: 0.461 -------------- |
To set the default to UTF-8, you want to add the following to my.cnf
1 2 3 4 5 6 7 8 9 10 |
[client] default-character-set=utf8 [mysql] default-character-set=utf8 [mysqld] collation-server = utf8_unicode_ci init-connect='SET NAMES utf8' character-set-server = utf8 |
One thought on “Mysql на CentOS 7”