centos7安装Mysql5.7(1)
安装hive之前,需要安装Mysql
* 下载官方mysql的rmp包
cat /etc/redhat-release CentOS Linux release 7.6.1810 (Core) # 进入/usr/local/src/路径,下载mysql的rpm包 cd /usr/local/mysql # 官网上最新的是8.0,也可以下载8.0的rpm,然后yum源安装的时候指定安装的版本,我这里直接下的5.7wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm ls mysql57-community-release-el7-11.noarch.rpm
* 卸载原生的mariadb
rpm -qa|grep mariadb mariadb-libs-5.5.60-1.el7_5.x86_64 yum remove mariadb-libs -y
* yum安装mysql-serve
rpm -ivh mysql57-community-release-el7-11.noarch.rpm warning: mysql57-community-release-el7-11.noarch.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY Preparing... ################################# [100%] Updating / installing... 1:mysql57-community-release-el7-11 ################################# [100%] yum -y install mysql-community-server
* 验证安装是否成功
# 开启mysql服务 systemctl start mysqld.service # 查看mysql状态 systemctl status mysqld.service ● mysqld.service - MySQL Server Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled) Active: active (running) since Mon 2019-08-05 12:19:50 EDT; 21s ago Docs: man:mysqld(8) http://dev.mysql.com/doc/refman/en/using-systemd.html Process: 16168 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS) Process: 16116 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS) Main PID: 16171 (mysqld) CGroup: /system.slice/mysqld.service └─16171 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid Aug 05 12:19:45 DW1 systemd[1]: Starting MySQL Server... Aug 05 12:19:50 DW1 systemd[1]: Started MySQL Server.
* 密码设置
# 生成初始密码 abwgxM&2B cat /var/log/mysqld.log|grep 'temporary password' 2019-08-05T16:19:46.809908Z 1 [Note] A temporary password is generated for root@localhost: abwgxM&2 B # 利用刚才生成的初始密码自定义新的密码 mysql -u root -p Enter password:
* 修改密码
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> #以此输入以下内容,就可以自定义的简单密码aaaaaa mysql> set global validate_password_policy=0; Query OK, 0 rows affected (0.00 sec) mysql> set global validate_password_length=1; Query OK, 0 rows affected (0.00 sec) mysql> set global validate_password_mixed_case_count=2; Query OK, 0 rows affected (0.00 sec) mysql> alter user 'root'@'localhost' identified by 'aaaaaa'; Query OK, 0 rows affected (0.00 sec)
* 重启mysql
# 重启mysql (base) [root@DW1 src]# service mysqld restart Redirecting to /bin/systemctl restart mysqld.service # 用我们刚才设置的简单密码aaaaaa登录 (base) [root@DW1 src]# 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.27 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. mysql>