62.在非元数据库节点安装MySQL

Posted 大勇若怯任卷舒

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了62.在非元数据库节点安装MySQL相关的知识,希望对你有一定的参考价值。

62.1 演示环境介绍

  • 系统为:RedHat7.2
  • 用sudo权限的ec2-user用户操作

62.2 操作演示

  • mysql5.7.12的RPM包下载
https://downloads.mysql.com/archives/community/
  • MySQL安装包上传至服务器并解压
    • 注意:解压出来的文件中,需要删除mysql-community-server-minimal-5.7.12-1.el7.x86_64.rpm,该RPM包和mysql-community-server-5.7.12-1.el7.x86_64.rpm冲突。
[ec2-user@ip-186-31-21-45 mysql5.7.12]$ tar -xvf mysql-5.7.12-1.el7.x86_64.rpm-bundle.tar 
[root@ip-186-31-26-102 mysql5.7.12]# ll
total 539776
-rw-r--r-- 1 ec2-user ec2-user  24991304 Mar 29  2016 mysql-community-client-5.7.12-1.el7.x86_64.rpm
-rw-r--r-- 1 ec2-user ec2-user    276736 Mar 29  2016 mysql-community-common-5.7.12-1.el7.x86_64.rpm
-rw-r--r-- 1 ec2-user ec2-user   3786120 Mar 29  2016 mysql-community-devel-5.7.12-1.el7.x86_64.rpm
-rw-r--r-- 1 ec2-user ec2-user  45150068 Mar 29  2016 mysql-community-embedded-5.7.12-1.el7.x86_64.rpm
-rw-r--r-- 1 ec2-user ec2-user  23829224 Mar 29  2016 mysql-community-embedded-compat-5.7.12-1.el7.x86_64.rpm
-rw-r--r-- 1 ec2-user ec2-user 124953868 Mar 29  2016 mysql-community-embedded-devel-5.7.12-1.el7.x86_64.rpm
-rw-r--r-- 1 ec2-user ec2-user   2237968 Mar 29  2016 mysql-community-libs-5.7.12-1.el7.x86_64.rpm
-rw-r--r-- 1 ec2-user ec2-user   2115948 Mar 29  2016 mysql-community-libs-compat-5.7.12-1.el7.x86_64.rpm
-rw-r--r-- 1 ec2-user ec2-user  51016520 Mar 29  2016 mysql-community-minimal-debuginfo-5.7.12-1.el7.x86_64.rpm
-rw-r--r-- 1 ec2-user ec2-user 158252992 Mar 29  2016 mysql-community-server-5.7.12-1.el7.x86_64.rpm
-rw-r--r-- 1 ec2-user ec2-user 116098332 Mar 29  2016 mysql-community-test-5.7.12-1.el7.x86_64.rpm

安装及配置

  • 命令如下
    • 在安装的过程中mariadb-libs.x86_64会被mysql-community-libs-compat和mysql-community-libs替换。
    • 在安装过程中可能会出现无法替换导致包冲突问题,需要手动卸载mariadb-libs.x84_64,因为cloudera-manager-agent服务依赖mariadb-libs.x86_64包,在卸载mariadb-libs.x84_64的时候需要注意,避免将Cloudera-manager-agent服务卸载。
[ec2-user@ip-186-31-26-102 mysql5.7.12]$ sudo yum -y install mysql-community-*
  • 启动MySQL服务并添加mysqld到自启动
[ec2-user@ip-186-31-21-45 log]$ sudo service mysqld start
[ec2-user@ip-186-31-21-45 log]$ sudo systemctl enable mysqld
  • MySQL的初始密码
    • MsSQL5.7.12版本安装完成后,已默认设置了初始密码,需要在/var/log/mysqld.log日志文件中查找初始密码。
  • 执行mysql_secure_installation脚本初始化MySQL
[ec2-user@ip-186-31-21-45 ~]$ mysql_secure_installation     

Securing the MySQL server deployment.

Enter password for user root: 

The existing password for the user account root has expired. Please set a new password.

New password: 

Re-enter new password: 
The 'validate_password' plugin is installed on the server.
The subsequent steps will run with the existing configuration
of the plugin.
Using existing password for root.

Estimated strength of the password: 100 
Change the password for root ? ((Press y|Y for Yes, any other key for No) : y

New password: 

Re-enter new password: 

Estimated strength of the password: 100 
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.

Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : n

 ... skipping.
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.

Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
 - Dropping test database...
Success.

 - Removing privileges on test database...
Success.

Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.

All done! 
[ec2-user@ip-186-31-21-45 ~]$ 
  • MySQL登录验证
[ec2-user@ip-186-31-21-45 ~]$ mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \\g.
Your MySQL connection id is 4
Server version: 5.7.12 MySQL Community Server (GPL)
…
Type 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.

mysql> 

验证建表SQL

  • 创建测试库
[ec2-user@ip-186-31-21-45 ~]$ mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \\g.
Your MySQL connection id is 5
Server version: 5.7.12 MySQL Community Server (GPL)
…
Type 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.
mysql> create database test;
Query OK, 1 row affected (0.00 sec)

mysql>
  • 导入sql
[ec2-user@ip-186-31-21-45 ~]$ mysql -uroot -p test < graph_api_test.sql 
Enter password: 
[ec2-user@ip-186-31-21-45 ~]$ 
  • cloudera manager agent服务依赖mariadb-libs.x86_64或mysql-libs.x86_64包,如果在卸载mariadb-libs.x86_64或mysql-libs.x86_64包时将相应的依赖包卸载,这样cloudera-manager-agent服务被卸载,就会导致安装节点的Agent服务异常。
    • 在RedHat7操作系统安装的过程中mariadb-libs.x86_64会被mysql-community-libs-compat和mysql-community-libs替换。

大数据视频推荐:
CSDN
大数据语音推荐:
企业级大数据技术应用
大数据机器学习案例之推荐系统
自然语言处理
大数据基础
人工智能:深度学习入门到精通

以上是关于62.在非元数据库节点安装MySQL的主要内容,如果未能解决你的问题,请参考以下文章

Mysql单实例的安装配置指南

《MySQL系列-主从相关》Docker安装MySQL,实现主从复制

windows mysql 5.5.62 安装

MySQL双主.md

linux在非root权限无外网(只有内网的生产环境)情况下安装nginx+mysql+php

Centos7 编译安装 MySQL 5.5.62