PS:近期因海外电商业务系统搭建,为方便配置MySQL数据库,实现业务高可用,快速构建自己的MySQL应用网站系统,
特研究了下MySQL数据库的配置初始化安装;特分享给大家
LINUX云服务器环境,8核16G-S5,500G-极速SSD盘;香港云服务器;
运行以下命令添加epel源。
yum install \ https://repo.ius.io/ius-release-el7.rpm \ https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
运行以下命令更新YUM源。
rpm -Uvh http://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
运行以下命令安装MySQL。
说明 如果您使用的操作系统内核版本为el8,可能会提示报错信息No match for argument。
您需要先运行命令yum module disable mysql禁用默认的MySQL模块,再安装MySQL。
yum -y install mysql-community-server
运行以下命令查看MySQL版本号。
mysql -V
返回结果如下所示,表示MySQL安装成功。
mysql Ver 14.14 Distrib 5.7.36, for Linux (x86_64) using EditLine wrapper
systemctl start mysqld
2. 依次运行以下命令设置开机启动MySQL。
systemctl enable mysqld systemctl daemon-reload
运行以下命令查看/var/log/mysqld.log文件,获取并记录root用户的初始密码。
grep 'temporary password' /var/log/mysqld.log
命令行返回结果如下,其中ARQTRy3+n8*W为MySQL的初始密码。在下一步重置root用户密码时,会使用该初始密码。
2022-11-10T07:01:26.595215Z 1 [Note] A temporary password is generated for root@localhost: ARQTRy3+n8*W
运行以下命令配置MySQL的安全性。
mysql_secure_installation
输入MySQL的初始密码。 说明 在输入密码时,系统为了最大限度的保证数据安全,命令行将不做任何回显。您只需要输入正确的密码信息,然后按Enter键即可。
Securing the MySQL server deployment. Enter password for user root: #输入上一步获取的root用户初始密码
为MySQL设置新密码。
The existing password for the user account root has expired. Please set a new password.
New password: #输入新密码。长度为8至30个字符,必须同时包含大小写英文字母、数字和特殊符号。特殊符号包含()` ~!@#$%^&*-+=|{}[]:;‘<>,.?/
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 #您需要输入Y以确认使用新密码。#新密码设置完成后,需要再次验证新密码。
New password:#再次输入新密码。 Re-enter new password:#再次确认新密码。
Estimated strength of the password: 100 Do you wish to continuewith the password provided?(Press y|Y for Yes, any other key for No) :Y #您需要输入Y,再次确认使用新密码。
输入Y删除匿名用户。
Removeanonymoususers?(Pressy|YforYes,anyotherkeyforNo):Y
Success.
输入Y禁止使用root用户远程登录MySQL
Disallowrootloginremotely?(Pressy|YforYes,anyotherkeyforNo):Y
Success.
Disallowrootloginremotely?(Pressy|YforYes,anyotherkeyforNo):Y Success.
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.
输入Y重新加载授权表。
Reloadprivilegetablesnow?(Pressy|YforYes,anyotherkeyforNo):Y
Success.All done!
腾讯云全新MySQL数据库上线,性能强劲,功能完备,支持千万级并发IOPS,新春活动,企业数字最经济实惠>>>>>>
腾讯云MySQL数据库专场:传送前往:https://cloud.tencent.com/act/cps/redirect?redirect=3563
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。