1. Download the MySQL installation package
下载地址:https://dev.mysql.com/downloads/mysql/
选择操作系统和版本
Select Operating System:
Red Hat Enterprise Linux/Oracle Linux
Select OS Version:
Red Hat Enterprise Linux 7 / Oracle Linux7
选择下载文件
RPM Bundle
2. Unzip the MySQL installation file to a local directory
tar -xvf mysql-5.7.19-1.el7.x86_64.rpm-bundle.tar
3. Use the rpm -ivh example.rpm command to install the following files in sequence
(1/5): mysql-community-common-5.7.19-1.el7.x86_64.rpm
(2/5): mysql-community-libs-5.7.19-1.el7.x86_64.rpm
(3/5): mysql-community-libs-compat-5.7.19-1.el7.x86_64.rpm
(4/5): mysql-community-client-5.7.19-1.el7.x86_64.rpm
(5/5): mysql-community-server-5.7
4. Start the MySQL service and check the startup status of MySQL
[root@ou Download]# systemctl start mysqld
[root@ou Download]# systemctl status mysqld
5. Start MySQL
[root@ou Download]# systemctl enable mysqld
[root@ou Download]# systemctl daemon-reload
6. Modify account and password After mysql is installed, a default password is generated for root in the /var/log/mysqld.log file. Find the
root default password in the following way, and then log in to mysql to modify it:
[root@ou Download]# grep 'temporary password' /var/log/mysqld.log
2018-04-08 [Note] A temporary password is generated for root@localhost: M=_s>fzl3d6p
mysql -u root -p
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'Lyo$$201171248$$';
或者
mysql> set password for 'root'@'localhost'=password('Lyo$$201171248$$');
7. Add a remote login user. By default, only the root account is allowed to log in locally. If you want to connect to mysql on other machines, you must modify root to allow remote connections, or
add an account that allows remote connections. For security, I add a new one account:
mysql> GRANT ALL PRIVILEGES ON *.* TO 'ouyang'@'%' IDENTIFIED BY 'Lyo$$201171248$$' WITH
GRANT OPTIO
8. Configure the default encoding to be utf8 Modify the /etc/my.cnf configuration file and add the encoding configuration under [mysqld], as shown below:
[mysqld]
character_set_server=utf8
init_connect='SET NAMES utf8'