[root@hadoop01 ~]# rpm -qa|grep mariadb
mariadb-libs-5.5.56-2.el7.x86_64
[root@hadoop01 ~]# rpm -e --nodeps mariadb-libs-5.5.56-2.el7.x86_64
[root@hadoop01 ~]# rpm -qa|grep mariadb
[root@hadoop01 mysql-5.7]# tar -xvf mysql-5.7.26-1.el7.x86_64.rpm-bundle.tar
mysql-community-embedded-devel-5.7.26-1.el7.x86_64.rpm
mysql-community-libs-5.7.26-1.el7.x86_64.rpm
mysql-community-embedded-5.7.26-1.el7.x86_64.rpm
mysql-community-test-5.7.26-1.el7.x86_64.rpm
mysql-community-embedded-compat-5.7.26-1.el7.x86_64.rpm
mysql-community-common-5.7.26-1.el7.x86_64.rpm
mysql-community-devel-5.7.26-1.el7.x86_64.rpm
mysql-community-client-5.7.26-1.el7.x86_64.rpm
mysql-community-server-5.7.26-1.el7.x86_64.rpm
mysql-community-libs-compat-5.7.26-1.el7.x86_64.rpm
[root@hadoop01 mysql-5.7]# rpm -ivh mysql-community-common-5.7.26-1.el7.x86_64.rpm
warning: mysql-community-common-5.7.26-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-common-5.7.26-1.e################################# [100%]
[root@hadoop01 mysql-5.7]# rpm -ivh mysql-community-libs-5.7.26-1.el7.x86_64.rpm
warning: mysql-community-libs-5.7.26-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-libs-5.7.26-1.el7################################# [100%]
[root@hadoop01 mysql-5.7]# rpm -ivh mysql-community-client-5.7.26-1.el7.x86_64.rpm
warning: mysql-community-client-5.7.26-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-client-5.7.26-1.e################################# [100%]
[root@hadoop01 mysql-5.7]# rpm -qa|grep libaio
libaio-0.3.109-13.el7.x86_64
rpm -ivh libaio-0.3.107-10.el6.x86_64.rpm(若在有网情况下可执行yum install libaio)
[root@hadoop01 mysql-5.7]# rpm -ivh mysql-community-server-5.7.26-1.el7.x86_64.rpm
warning: mysql-community-server-5.7.26-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-server-5.7.26-1.e################################# [100%]
// 指定datadir, 执行后会生成~/.mysql_secret密码文件(5.7以后不在使用)
[root@hadoop01 mysql-5.7]# mysql_install_db --datadir=/var/lib/mysql
// 初始化,执行生会在/var/log/mysqld.log生成随机密码
[root@hadoop01 mysql-5.7]# mysqld --initialize
[root@hadoop01 mysql-5.7]# chown mysql:mysql /var/lib/mysql -R
[root@hadoop01 mysql-5.7]# systemctl start mysqld.service
[root@hadoop01 mysql-5.7]# chmod -R 777 mysql
[root@hadoop01 mysql-5.7]# systemctl status mysqld.service
命令可以查看初始密码
grep 'temporary password' /var/log/mysqld.log
[root@hadoop01 mysql-5.7]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.26 MySQL Community Server (GPL)
Copyright (c) 2000, 2019, 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.
# 修改root用户的密码
mysql> set password=password('你要修改的密码');
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 1
# 刷新该表
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
# 退出MySQL
mysql> quit;
Bye
[root@hadoop01 mysql-5.7]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.26 MySQL Community Server (GPL)
Copyright (c) 2000, 2019, 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.
# root用户远程登录
mysql> grant all privileges on *.* to 'root'@'%' identified by '你的密码' with grant option;
Query OK, 0 rows affected, 1 warning (0.00 sec)
# 刷新表
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
# 退出MySQL
mysql> quit;
Bye
// 检查是否已经是开机启动
[root@hadoop01 mysql-5.7]# systemctl list-unit-files | grep mysqld
// 开机启动
[root@hadoop01 mysql-5.7]# systemctl enable mysqld.service
配置文件:/etc/my.cnf
日志文件:/var/log/mysqld.log
服务启动脚本:/usr/lib/systemd/system/mysqld.service
socket文件:/var/run/mysqld/mysqld.pid
修改/etc/my.cnf配置文件,在[mysqld]下添加编码配置,如下所示:
[mysqld]
character_set_server=utf8
init_connect='SET NAMES utf8'