机器是CentOS7.0
安装mysql
在mysql官网下载mysql-community-release-el7-5.noarch.rpm
rpm -ivh mysql-community-release-el7-5.noarch.rpm
yum install mysql-community-server
过程如下:
[root@localhost network-scripts]# cd /root/Desktop/
[root@localhost Desktop]# ls
mysql57-community-release-el7-7.noarch.rpm
[root@localhost Desktop]# rpm -ivh mysql57-community-release-el7-7.noarch.rpm
warning: mysql57-community-release-el7-7.noarch.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:mysql57-community-release-el7-7 ################################# [100%]
[root@localhost Desktop]# yum install mysql-community-release
Loaded plugins: fastestmirror, langpacks
Existing lock /var/run/yum.pid: another copy is running as pid 3326.
Another app is currently holding the yum lock; waiting for it to exit...
The other application is: PackageKit
Memory : 102 M RSS (432 MB VSZ)
Started: Tue Jan 26 21:04:26 2016 - 05:40 ago
State : Sleeping, pid: 3326
^C
Exiting on user cancel.
[root@localhost Desktop]# yum install mysql-community-server
Loaded plugins: fastestmirror, langpacks
Existing lock /var/run/yum.pid: another copy is running as pid 3326.
Another app is currently holding the yum lock; waiting for it to exit...
The other application is: PackageKit
Memory : 102 M RSS (432 MB VSZ)
Started: Tue Jan 26 21:04:26 2016 - 05:47 ago
State : Sleeping, pid: 3326
Another app is currently holding the yum lock; waiting for it to exit...
The other application is: PackageKit
Memory : 102 M RSS (432 MB VSZ)
Started: Tue Jan 26 21:04:26 2016 - 05:49 ago
State : Sleeping, pid: 3326
^C
Exiting on user cancel.
[root@localhost Desktop]# kill 3326
[root@localhost Desktop]# yum install mysql-community-server
Loaded plugins: fastestmirror, langpacks
base | 3.6 kB 00:00
extras | 3.4 kB 00:00
mysql-connectors-community | 2.5 kB 00:00
mysql-tools-community | 2.5 kB 00:00
mysql57-community | 2.5 kB 00:00
updates | 3.4 kB 00:00
(1/4): mysql-connectors-community/x86_64/primary_db | 8.6 kB 00:00
(2/4): updates/7/x86_64/primary_db | 2.3 MB 00:00
(3/4): mysql57-community/x86_64/primary_db | 28 kB 00:00
(4/4): mysql-tools-community/x86_64/primary_db | 24 kB 00:00
Loading mirror speeds from cached hostfile
* base: mirrors.zju.edu.cn
* extras: mirrors.zju.edu.cn
* updates: mirrors.zju.edu.cn
Resolving 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.35-3.el7 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 Resolution
Dependencies 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.35-3.el7
mysql-community-libs-compat x86_64 5.7.10-1.el7 mysql57-community 2.0 M
replacing mariadb-libs.x86_64 1:5.5.35-3.el7
mysql-community-server x86_64 5.7.10-1.el7 mysql57-community 142 M
Installing 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 k
Transaction Summary
================================================================================
Install 3 Packages (+2 Dependent packages)
Total download size: 171 M
Is this ok [y/d/N]: y
Downloading packages:
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: NOKEY
Public key for mysql-community-common-5.7.10-1.el7.x86_64.rpm is not installed
(1/5): mysql-community-common-5.7.10-1.el7.x86_64.rpm | 269 kB 00:07
(2/5): mysql-community-libs-5.7.10-1.el7.x86_64.rpm | 2.2 MB 00:20
(3/5): mysql-community-libs-compat-5.7.10-1.el7.x86_64.rpm | 2.0 MB 00:15
(4/5): mysql-community-client-5.7.10-1.el7.x86_64.rpm | 24 MB 03:06
(5/5): mysql-community-server-5.7.10-1.el7.x86_64.rpm | 142 MB 20:39
--------------------------------------------------------------------------------
Total 136 kB/s | 171 MB 21:23
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Importing 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 (installed)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
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.35-3.el7.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.35-3.el7.x86_64 6/6
Installed:
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.el7
Dependency Installed:
mysql-community-client.x86_64 0:5.7.10-1.el7
mysql-community-common.x86_64 0:5.7.10-1.el7
Replaced:
mariadb-libs.x86_64 1:5.5.35-3.el7
Complete!
启动mysql服务
service mysqld start
mysql
找了网上的教程,在my.cnf中加入 user=mysql也不行
如何才能进入mysql
mysql5.7.10刚安装好,会生成一个随机密码。
如果没记住这个随机密码,那么到mysql/bin/下执行mysql_secure_installation命令
按照提示重置密码和其他选项。
ps:找了一下午终于找到方法了!!!