首页 > 数据库 >云环境安装数据库快速完成流程

云环境安装数据库快速完成流程

时间:2023-02-21 15:45:59浏览次数:33  
标签:service 安装 数据库 systemctl mysqld MySQL password root 流程

华为指导云主机mysql安装流程:

前言,最近需要在云主机在搞一台数据库做新测试,传统二进制安装太麻烦,提交了华为工单,得到了华为工程师发来的文档,然后照着完成了从安装到配置的过程,做了一个笔记供以后需要在查看。

以下操作为华为发的资料记录,比较精简快速安装数据库,比网上教程精简多了。

第一步安装数据库。以下资料来源于华为技术整理

安装MySQL。

依次执行以下命令,安装MySQL。

wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm

 

yum -y install mysql57-community-release-el7-10.noarch.rpm

 

yum -y install mysql-community-server --nogpgcheck

 

依次执行以下命令,启动MySQL服务并设置开机自启动。

systemctl start mysqld

 

systemctl enable mysqld

 

查看MySQL运行状态。

systemctl status mysqld.service

 

 

[root@ecs-adc3 ~]# 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 2021-08-16 19:33:40 CST; 36s ago

     Docs: man:mysqld(8)

           http://dev.mysql.com/doc/refman/en/using-systemd.html

 Main PID: 7916 (mysqld)

   CGroup: /system.slice/mysqld.service

           └─7916 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid

 

Aug 16 19:33:35 ecs-adc3 systemd[1]: Starting MySQL Server...

Aug 16 19:33:40 ecs-adc3 systemd[1]: Started MySQL Server.

 

 

执行以下命令,获取安装MySQL时自动设置的root用户密码。

grep 'temporary password' /var/log/mysqld.log

 

回显如下类似信息。

 

2018-08-29T07:27:37.541944Z 1 [Note] A temporary password is generated for root@localhost: 2YY?3uHUA?Ys

 

执行以下命令,并按照回显提示信息进行操作,加固MySQL。

mysql_secure_installation

 

 

Securing the MySQL server deployment.

 

Enter password for user root:    #输入上一步骤中获取的安装MySQL时自动设置的root用户密码

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

 

New password:  #设置新的root用户密码

 

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) : N   #是否更改root用户密码,输入N

 

 ... skipping.

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   #是否删除匿名用户,输入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) : Y   #禁止root远程登录,输入Y

Success.

 

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   #是否删除test库和对它的访问权限,输入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   #是否重新加载授权表,输入Y

Success.

 

All done!

 

以上为安装过程,接下来记录配置过程。

 

 

 

 

 

 

 

配置流程

在配置以下操作时需要登录数据库使用命令登陆
mysql -h localhost -u root -P 3306 -p

 

配置用户和地址权限

让root 用户可以登陆所有帐户

create user 'root'@'%' identified by '3RSG1v7Sz,iv'

设置权限,任何地方都能登

grant all privileges on *.* to 'root'@'%' with grant option;

刷新权限

flush privileges

 

exit  退出登陆数据库进行全局端口配置

 

配置端口 3306,通过以下命令开启3306

firewall-cmd --zone=public --add-port=3306/tcp --permanent

firewall-cmd --reload  重启防火墙

查看开启的端口

firewall-cmd --list-port  

云服务器需要配置安全组,以上操作完成mysql配置数据库

 

如有不行可能需要重启计算机   

 

有时候需要操作防火墙,关于防火墙相方面,关掉防火墙,以下是附属技术,关于防火墙

1、命令行界面输入命令“systemctl status firewalld.service”并按下回车键。

 

2、然后在下方可度以查看得到“active(running)”,此时说明防火墙已经被打开了。

 

3、在命令行中输入systemctl stop firewalld.service命令,进行关闭防火墙。

 

4、然后再使用命令systemctl status firewalld.service,在下方出现disavtive(dead),这权样就说明防火墙已经关闭。

 

5、再在命令行中输入命令“systemctl disable firewalld.service”命令,即可永久关闭防火

 

标签:service,安装,数据库,systemctl,mysqld,MySQL,password,root,流程
From: https://www.cnblogs.com/fgxwan/p/17141193.html

相关文章

  • Windows家庭版安装本地组策略编辑器【gpedit.msc】
    由于我们买的电脑一般默认安装的Windows家庭版本家庭版本默认不带有本地组策略编辑器当我们运行gpedit.msc的时候会提示Winodws找不到文件'gpedit.msc'。请确定文件名是......
  • 基于uniGUI的第三方控件Unifalcon的安装(60)
    链接:https://pan.xunlei.com/s/VNOmoEQ3GajxTxfyPmflp0OtA1#提取码:5tx9迅雷网盘参考https://blog.csdn.net/sglqh/article/details/83339490Unifalcon是一组基于unigui......
  • 数据库约束
    约束字段约束:比如创建一个age列,这里设置了字段类型为int,所以这里只能填int,不能填其他的类型约束是保证数据准确性的最后一道屏障,即为了保证表中的数据有效性非空约束(n......
  • centos安装node.js
    本文的示例步骤中,使用的软件版本信息如下所述。当您使用不同软件版本时,需要根据实际情况自行调整命令和参数配置。最好安装前先备份快照CentOS版本:7.6Node.js版本:16.4.2......
  • Git安装教程
    2018年4月14日更新 更新使用总的问题今天重新安装一下Git软件;就详细的记录一下安装步骤;毕竟自己的系列还差各位一个许诺;其实安装非常简单;但是具体的含义;大家一定要明......
  • MySQL安装及配置
    Mysql本质上是一个软件  8.x,5.x  本人采用5.7.31版本(既支持win又支持mac)下载地址:https://downloads.mysql.com/archives/community/本人经常使用的为:链接:https......
  • Navicat连接不上数据库
    原因:服务没有启动解决:右键点击我的电脑》管理》服务》找到MYSQL,点击启动即可 ......
  • (数据库系统概论|王珊)第六章关系数据理论-第一节:为什么要研究关系数据理论
    ​​pdf下载:密码7281​​​​专栏目录首页:【专栏必读】(考研复试)数据库系统概论第五版(王珊)专栏学习笔记目录导航及课后习题答案详解​​一句话,研究关系数据库理论就是为了设......
  • SQL Server数据库日常检查
    1.1代码检查从昨天到现在,SQL代理Job有没有运行失败的,会把运行失败的Job名字,步骤,运行时间,错误等级,错误原因罗列出来,方便查看。----1.1  Check Job Fail List From L......
  • M1安装PD tools linux-headers报错
    1.报错信息Anerroroccurredwhileinstallingthefollowingpackages:-linux-headers-5.18.0-kali5-arm64InstallthesepackagesmanuallyandstarttheParall......