使用YUM安装并启动MySQL服务后,MySQL进程会自动在进程日志中打印root用户的初始密码
来源:互联网 发布:netstat linux 安装 编辑:程序博客网 时间:2024/05/16 17:25
https://typecodes.com/linux/yuminstallmysql5710.html
CentOS 7.2使用yum安装MYSQL 5.7.10
前面两篇文章《2015博客升级记(四):CentOS 7.1编译安装MySQL5.7.7rc》、《阿里云CentOS 7.1使用yum安装MySql5.6.24》分别使用源码编译和YUM方法安装MySQL数据库,这篇文章同样是使用YUM方法在CentOS7.2(64bits)的机器上安装最新的MySQL5.7.10数据库。
1 查看Linux发行版本
[root@typecodes ~]# cat /etc/redhat-releaseCentOS 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 linstall 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数据库的服务器版本
[root@typecodes ~]# yum -y install mysql-community-serverLoaded plugins: axelget, fastestmirror, langpacksNo metadata available for baseNo metadata available for epelNo metadata available for extrasrepomd.xml | 2.5 kB 00:00:00 update mysql-connectors-community metadata successfullyrepomd.xml | 2.5 kB 00:00:00 update mysql-tools-community metadata successfullyrepomd.xml | 2.5 kB 00:00:00 update mysql57-community metadata successfullyNo metadata available for updatesmysql-connectors-community | 2.5 kB 00:00:00 mysql-tools-community | 2.5 kB 00:00:00 mysql57-community | 2.5 kB 00:00:00 (1/3): mysql-tools-community/x86_64/primary_db | 24 kB 00:00:01 (2/3): mysql57-community/x86_64/primary_db | 28 kB 00:00:01 (3/3): mysql-connectors-community/x86_64/primary_db | 8.6 kB 00:00:02 Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * epel: mirrors.neusoft.edu.cn * extras: mirrors.163.com * updates: mirrors.163.comResolving Dependencies--> Running transaction check---> Package mysql-community-server.x86_64 0:5.7.10-1.el7 will be installed--> Processing Dependency: mysql-community-common(x86-64) = 5.7.10-1.el7 for package: mysql-community-server-5.7.10-1.el7.x86_64--> Processing Dependency: mysql-community-client(x86-64) = 5.7.10-1.el7 for package: mysql-community-server-5.7.10-1.el7.x86_64--> Running transaction check---> Package mysql-community-client.x86_64 0:5.7.10-1.el7 will be installed--> Processing Dependency: mysql-community-libs(x86-64) = 5.7.10-1.el7 for package: mysql-community-client-5.7.10-1.el7.x86_64---> Package mysql-community-common.x86_64 0:5.7.10-1.el7 will be installed--> Running transaction check---> Package mariadb-libs.x86_64 1:5.5.44-2.el7.centos will be obsoleted--> Processing Dependency: libmysqlclient.so.18()(64bit) for package: 2:postfix-2.10.1-6.el7.x86_64--> Processing Dependency: libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: 2:postfix-2.10.1-6.el7.x86_64---> Package mysql-community-libs.x86_64 0:5.7.10-1.el7 will be obsoleting--> Running transaction check---> Package mysql-community-libs-compat.x86_64 0:5.7.10-1.el7 will be obsoleting--> Finished Dependency ResolutionDependencies Resolved======================================================================================================================================================================= Package Arch Version Repository Size=======================================================================================================================================================================Installing: mysql-community-libs x86_64 5.7.10-1.el7 mysql57-community 2.2 M replacing mariadb-libs.x86_64 1:5.5.44-2.el7.centos mysql-community-libs-compat x86_64 5.7.10-1.el7 mysql57-community 2.0 M replacing mariadb-libs.x86_64 1:5.5.44-2.el7.centos mysql-community-server x86_64 5.7.10-1.el7 mysql57-community 142 MInstalling for dependencies: mysql-community-client x86_64 5.7.10-1.el7 mysql57-community 24 M mysql-community-common x86_64 5.7.10-1.el7 mysql57-community 269 kTransaction Summary=======================================================================================================================================================================Install 3 Packages (+2 Dependent packages)Total download size: 171 MDownloading packages:mysql-community-server-5.7.10-1.el7.x86_64.rpm | 142 MB 00:03:42 mysql-community-libs-compat-5.7.10-1.el7.x86_64.rpm | 2.0 MB 00:00:03 mysql-community-libs-5.7.10-1.el7.x86_64.rpm | 2.2 MB 00:00:05 mysql-community-client-5.7.10-1.el7.x86_64.rpm | 24 MB 00:00:41 warning: /var/cache/yum/x86_64/7/mysql57-community/packages/mysql-community-common-5.7.10-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY00 ETA Public key for mysql-community-common-5.7.10-1.el7.x86_64.rpm is not installedmysql-community-common-5.7.10-1.el7.x86_64.rpm | 269 kB 00:00:01 Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysqlImporting GPG key 0x5072E1F5: Userid : "MySQL Release Engineering <mysql-build@oss.oracle.com>" Fingerprint: a4a9 4068 76fc bd3c 4567 70c8 8c71 8d3b 5072 e1f5 Package : mysql57-community-release-el7-7.noarch (@/mysql57-community-release-el7-7.noarch) From : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysqlRunning transaction checkRunning transaction testTransaction test succeededRunning transaction Installing : mysql-community-common-5.7.10-1.el7.x86_64 1/6 Installing : mysql-community-libs-5.7.10-1.el7.x86_64 2/6 Installing : mysql-community-client-5.7.10-1.el7.x86_64 3/6 Installing : mysql-community-server-5.7.10-1.el7.x86_64 4/6 Installing : mysql-community-libs-compat-5.7.10-1.el7.x86_64 5/6 Erasing : 1:mariadb-libs-5.5.44-2.el7.centos.x86_64 6/6 Verifying : mysql-community-server-5.7.10-1.el7.x86_64 1/6 Verifying : mysql-community-libs-compat-5.7.10-1.el7.x86_64 2/6 Verifying : mysql-community-common-5.7.10-1.el7.x86_64 3/6 Verifying : mysql-community-libs-5.7.10-1.el7.x86_64 4/6 Verifying : mysql-community-client-5.7.10-1.el7.x86_64 5/6 Verifying : 1:mariadb-libs-5.5.44-2.el7.centos.x86_64 6/6Installed: mysql-community-libs.x86_64 0:5.7.10-1.el7 mysql-community-libs-compat.x86_64 0:5.7.10-1.el7 mysql-community-server.x86_64 0:5.7.10-1.el7Dependency Installed: mysql-community-client.x86_64 0:5.7.10-1.el7 mysql-community-common.x86_64 0:5.7.10-1.el7Replaced: mariadb-libs.x86_64 1:5.5.44-2.el7.centosComplete![root@typecodes ~]# clear
最后的截图:
4 启动数据库:
[root@typecodes ~]# systemctl start mysqld.service
然后使用命令systemctl status mysql.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用户的初始密码,然后进行修改:
[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> exitBye
7 安装完毕
至此,使用在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:删除MySQL的Repository
因为小节3中安装了MySQL的Yum Repository,所以以后每次执行yum操作时,都会去检查更新。如果想要去掉这种自动检查操作的话,可以使用如下命令卸载MySQL的Repository即可。
[root@typecodes ~]# yum -y remove mysql57-community-release-el7-7.noarch
- 使用YUM安装并启动MySQL服务后,MySQL进程会自动在进程日志中打印root用户的初始密码
- yum安装mysql后root用户的临时密码
- CentOS6.7下使用非root用户(普通用户)编译安装与配置mysql数据库并使用shell脚本定时任务方式实现mysql数据库服务随机自动启动
- MySQL 安装和启动服务,“本地计算机 上的 MySQL 服务启动后停止。某些服务在未由其他服务或程序使用时将自动停止。”
- MySQL 安装和启动服务,“本地计算机 上的 MySQL 服务启动后停止。某些服务在未由其他服务或程序使用时将自动停止。
- MySQL 安装和启动服务,“本地计算机 上的 MySQL 服务启动后停止。某些服务在未由其他服务或程序使用时将自动停止。”
- MySql安装之后无法启动服务(如在管理中打开显示进程意外终止)
- mysql安装后初始密码的设置
- windows 10安装mysql 5.7后,启动服务提示“本地计算机上的mysql服务启动后停止,某些服务在未由其他服务或程序使用时将自动停止。
- 在管理工具的服务中启动mysql服务时都会在中途报错。内容为:在 本地计算机 无法启动mysql服务 错误1067:进程意外中止。
- 安装MySQL,本地计算机上的服务启动后停止。某些服务在未由其他服务或程序使用时将自动停止
- 安装MySQL,本地计算机上的服务启动后停止。某些服务在未由其他服务或程序使用时将自动停止
- MySQL 启动服务错误:“本地计算机 上的 MySQL 服务启动后停止。某些服务在未由其他服务或程序使用时将自动停止。”
- 如何让window服务进程中自动加载MYSQL服务
- 在CentOS 6.3 64bit下yum安装MySQL后重置root密码的方法
- mysql安装后默认就会自动启动了
- mac中mysql的root账户初始密码忘记的解决办法
- centos7 设置下使用yum安装mysql并创建用户
- 十一月后google chrome浏览器将不再占用那么多内存
- 你所不知道的按位运算
- linux文件压缩和压缩常用命令小结
- App 上架流程
- Nginx实战(三) 日志配置与切割
- 使用YUM安装并启动MySQL服务后,MySQL进程会自动在进程日志中打印root用户的初始密码
- 欢迎使用CSDN-markdown编辑器
- 预处理-分节6(#pragma 下)
- Revit开发之判断参数是否为项目参数
- 函数的声明和定义
- linux(centos)下mysql安装搭建配置
- Fortran调用C语言小计
- PAT 1092. To Buy or Not to Buy (20)(字符串操作)
- 点击label时click事件被触发两次的坑