LNMP架构超详细教程(三)MySQL之rpm包安装教程

1】安装包下载

在浏览器中搜索mysql进入mysql官网下载安装包


选择download,然后滑到底部选择社区版下载(专业版收费):

然后选择下图中标记的那一项:

往下滑,根据自己系统选择操作系统类型,然后下载第一项,如下图:

2】解压安装包

[root@localhost RANDOM]# file mysql-5.7.22-1.el7.x86_64.rpm-bundle.tar 
mysql-5.7.22-1.el7.x86_64.rpm-bundle.tar: POSIX tar archive (GNU)

软件包为tar包,直接使用下面的命令解压:

tar  xf   mysql-5.7.22-1.el7.x86_64.rpm-bundle.tar

3】安装软件

解压后会有很多rpm包,但是你只需要安装下面五个安装包即可:

 mysql-community-client.x86_64 0:5.7.22-1.el7                                  
  mysql-community-common.x86_64 0:5.7.22-1.el7                                  
  mysql-community-libs.x86_64 0:5.7.22-1.el7                                    
  mysql-community-libs-compat.x86_64 0:5.7.22-1.el7                             
  mysql-community-server.x86_64 0:5.7.22-1.el7  

4】数据库初始化

  1)开启数据库: 

[root@server1 ~]# systemctl start mysqld

2)数据库第一次启动系统会自动生成一个初始密码,这个密码保存在/var/log/mysql.log里面,通过下面命令提取密码:

[root@server1 ~]# cat /var/log/mysqld.log | grep localhost
2018-05-23T12:29:44.524656Z 1 [Note] A temporary password is generated for rootlocalhost: 0wfFPouUsw:.

红色字体即为初始密码。

3)设置密码

通过下面指令进入数据库配置环境:

[root@server1 ~]# 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 注:给root用户设置密码,输入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 注:选择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) : y
注:不允许root用户远程登陆。
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
注:移除测试数据。
 - 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! 

5】数据库登陆

[root@server1 ~]# mysql -uroot -p
Enter password: 注:输入你设置的密码。
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.7.22 MySQL Community Server (GPL)

Copyright (c) 2000, 2018, 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> 



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值