时间:2021-05-25
1查看Linux发行版本
[root@typecodes ~]# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)
2 下载MySQL官方的Yum Repository
根据Linux发行版本(CentOS、Fedora都属于红帽系),从mysql官方(http://dev.mysql.com/downloads/repo/yum/)获取Yum Repository。
[root@typecodes ~]# wget -i http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm--2016-02-03 18:36:02-- http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpmResolving dev.mysql.com (dev.mysql.com)... 137.254.60.11Connecting to dev.mysql.com (dev.mysql.com)|137.254.60.11|:80... connected.HTTP request sent, awaiting response... 302 FoundLocation: http://repo.mysql.com//mysql57-community-release-el7-7.noarch.rpm [following]--2016-02-03 18:36:04-- http://repo.mysql.com//mysql57-community-release-el7-7.noarch.rpmResolving repo.mysql.com (repo.mysql.com)... 104.102.164.25Connecting to repo.mysql.com (repo.mysql.com)|104.102.164.25|:80... connected.HTTP request sent, awaiting response... 200 OKLength: 8984 (8.8K) [application/x-redhat-package-manager]Saving to: ‘mysql57-community-release-el7-7.noarch.rpm'100%[=============================================================================================================================>] 8,984 --.-K/s in 0s2016-02-03 18:36:07 (68.4 MB/s) - ‘mysql57-community-release-el7-7.noarch.rpm' saved [8984/8984]3 安装MySQL的Yum Repository安装完MySQL的Yum Repository,每次执行yum update都会检查MySQL是否更新。[root@typecodes ~]# yum -y install mysql57-community-release-el7-7.noarch.rpmLoaded plugins: axelget, fastestmirror, langpacksExamining mysql57-community-release-el7-7.noarch.rpm: mysql57-community-release-el7-7.noarchMarking mysql57-community-release-el7-7.noarch.rpm to be installedResolving Dependencies--> Running transaction check---> Package mysql57-community-release.noarch 0:el7-7 will be installed--> Finished Dependency ResolutionDependencies Resolved======================================================================================================================================================================= Package Arch Version Repository Size=======================================================================================================================================================================Installing: mysql57-community-release noarch el7-7 /mysql57-community-release-el7-7.noarch 7.8 kTransaction Summary=======================================================================================================================================================================Install 1 PackageTotal size: 7.8 kInstalled size: 7.8 kDownloading packages:Running transaction checkRunning transaction testTransaction test succeededRunning transaction Installing : mysql57-community-release-el7-7.noarch 1/1 Verifying : mysql57-community-release-el7-7.noarch 1/1Installed: mysql57-community-release.noarch 0:el7-7Complete!3 安装MySQL数据库的服务器版本
最后的截图:
4 启动数据库:
[root@typecodes ~]# systemctl start mysqld.service然后使用命令systemctl status mysqld.service查看MySQL数据库启动后的服务状态:
5 获取初始密码
使用YUM安装并启动MySQL服务后,MySQL进程会自动在进程日志中打印root用户的初始密码:
#######从mysql进程日志中获取root用户的初始密码:ra%yk7urCBIh[root@typecodes ~]# grep "password" /var/log/mysqld.log2016-02-03T10:42:17.272166Z 1 [Note] A temporary password is generated for root@localhost: ra%yk7urCBIh2016-02-03T10:42:36.776875Z 2 [Note] Access denied for user 'root'@'localhost' (using password: NO)2016-02-03T10:42:52.063138Z 3 [Note] Access denied for user 'root'@'localhost' (using password: NO)2016-02-03T10:42:57.564373Z 4 [Note] Access denied for user 'root'@'localhost' (using password: NO)2016-02-03T10:43:01.477007Z 5 [Note] Access denied for user 'root'@'localhost' (using password: NO)2016-02-03T10:46:03.642008Z 6 [Note] Access denied for user 'root'@'localhost' (using password: NO)2016-02-03T10:46:11.217889Z 7 [Note] Access denied for user 'root'@'localhost' (using password: NO)2016-02-03T10:47:44.755199Z 0 [Note] Shutting down plugin 'validate_password'2016-02-03T10:47:46.505844Z 0 [Note] Shutting down plugin 'sha256_password'2016-02-03T10:47:46.505851Z 0 [Note] Shutting down plugin 'mysql_native_password'6 修改root用户密码
使用小节5中获取的root用户的初始密码,然后进行修改:
set global validate_password_policy =0;//默认是1,即MEDIUM,所以刚开始设置的密码必须符合长度,且必须含有数字,小写或大写字母,特殊字符。
增加远程访问权限
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'crow' WITH GRANT OPTION;FLUSH PRIVILEGES;退出mysql,然后重启服务
systemctl restart mysqld防火墙打开3306端口
firewall-cmd --zone=public --add-port=3306/tcp --permanent重启防火墙
firewall-cmd --reload[root@typecodes ~]# mysql -uroot -pEnter password: #######输入默认的root密码后回车Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 2Server version: 5.7.10Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password';Query OK, 0 rows affected (0.00 sec)mysql> exitBye7 安装完毕
至此,使用在CentOS7中使用YUM方法安装MySQL5.7.10数据库完毕。如下所示,可以使用新的root密码登陆MySQL了。
[root@typecodes ~]# mysql -uroot -ppasswordmysql: [Warning] Using a password on the command line interface can be insecure.Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 3Server version: 5.7.10 MySQL Community Server (GPL)Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> use mysql;Reading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -ADatabase changedmysql> show databases;+--------------------+| Database |+--------------------+| information_schema || mysql || performance_schema || sys |+--------------------+4 rows in set (0.00 sec)mysql> clearmysql> exitBye[root@typecodes ~]# clear附录1:查看MySQL数据库的配置信息
MySQL的配置文件依然是/etc/my.cnf,其它安装信息可以通过mysql_config命令查看。其中,动态库文件存放在/usr/lib64/mysql目录下。
附录2:对于C/C++等开发者
由于需要用到类似mysql.h等头文件,需要执行下面的命令安装mysql开发版本即可。
[root@typecodes ~]# yum -y install mysql-community-devel附录3:删除MySQL的Repository
因为小节3中安装了MySQL的Yum Repository,所以以后每次执行yum操作时,都会去检查更新。如果想要去掉这种自动检查操作的话,可以使用如下命令卸载MySQL的Repository即可。
[root@typecodes ~]# yum -y remove mysql57-community-release-el7-7.noarchupdate 2017.04.10 11:10使用上面的yum方法也可以安装目前mysql官网上最新的版本mysql5.7.18。只要替换小节2中rmp包的版本即可,后续操作步骤不变。
wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm以上所述是小编给大家介绍的centos7.3 安装mysql5.7.18的详细教程,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对网站的支持!
声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
本文为大家分享了Centos7.3下mysql5.7.18的安装,和修改初始密码,供大家参考,具体内容如下1、官方安装文档http://dev.mysql.co
本教程为大家分享了mysql5.7.18安装配置方法,供大家参考,具体内容如下一、mysql5.7.18安装配置1、MySQL下载:https:///downl
本文是基于CentOS7.3系统环境,进行MySQL和Redis的安装和使用CentOS7.3Docker-ce一、安装MySQL镜像(1)拉取MySQL镜像d
Centos安装MySQL可以参考之前写的一篇文章Centos7.3安装Mysql5.7并修改初始密码windows安装mysql5.7有两种方式1、下载.ms
centos6.4下安装mysql5.7.18的具体步骤,分享给大家。1、首先检查是否已经安装过mysql,查找mysql相关软件rpm包#rpm-qa|gre