码迷,mamicode.com
首页 > 数据库 > 详细

CentOS下yum安装mysql

时间:2019-05-04 09:38:22      阅读:2436      评论:0      收藏:0      [点我收藏+]

标签:OLE   col   大小写   redirect   upgrade   std   word   cache   cat   

  其实跟windows下安装过程差别不大,就是下载为了方便使用了yum的方式。安装前先确认下系统是否还安装mysql,卸载是否不完全,再去官网(http://dev.mysql.com/downloads/repo/yum/)选一个yum版本,这里我选了最新的mysql80-community-release-el7-3.noarch.rpm,通过wget下载后就可以安装mysql服务端了,然后就算完了。是不是很简单?当然为了使用方便,跟windows的一样,最好再改下初始密码。下面看下操作记录:

1、检查下是否已下载还有卸载残留

# rpm -qa | grep mysql
# find / -name mysql /etc/selinux/targeted/active/modules/100/mysql /usr/lib64/mysql /usr/share/mysql

  看来还是有的,通过rm -rf将以上目录删掉即可,另外顺便把配置文件/etc/my.cnf也删掉吧,用rm -f。

2、安装yum

# wget http://repo.mysql.com/mysql80-community-release-el7-3.noarch.rpm
--2019-05-04 07:00:43--  http://repo.mysql.com/mysql80-community-release-el7-3.noarch.rpm
Resolving repo.mysql.com (repo.mysql.com)... 23.41.23.231
Connecting to repo.mysql.com (repo.mysql.com)|23.41.23.231|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 26024 (25K) [application/x-redhat-package-manager]
Saving to: 鈥榤ysql80-community-release-el7-3.noarch.rpm鈥

100%[==============================================================================================================================>] 26,024      --.-K/s   in 0.1s    

2019-05-04 07:00:43 (223 KB/s) - 鈥榤ysql80-community-release-el7-3.noarch.rpm鈥saved [26024/26024]

3、安装mysql

# sudo rpm -Uvh mysql80-community-release-el7-3.noarch.rpm
warning: mysql80-community-release-el7-3.noarch.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql80-community-release-el7-3  ################################# [100%]
[root@VM_0_17_centos mysql]# yum install -y mysql-community-server
Loaded plugins: fastestmirror, langpacks
epel                                                                                                                                             | 4.7 kB  00:00:00     
extras                                                                                                                                           | 3.4 kB  00:00:00     
mysql-connectors-community                                                                                                                       | 2.5 kB  00:00:00     
mysql-tools-community                                                                                                                            | 2.5 kB  00:00:00     
mysql80-community                                                                                                                                | 2.5 kB  00:00:00     
os                                                                                                                                               | 3.6 kB  00:00:00     
updates                                                                                                                                          | 3.4 kB  00:00:00     
(1/7): extras/7/x86_64/primary_db                                                                                                                | 201 kB  00:00:00     
(2/7): epel/7/x86_64/updateinfo                                                                                                                  | 991 kB  00:00:00     
(3/7): epel/7/x86_64/primary_db                                                                                                                  | 6.7 MB  00:00:00     
(4/7): mysql-connectors-community/x86_64/primary_db                                                                                              |  41 kB  00:00:00     
(5/7): mysql-tools-community/x86_64/primary_db                                                                                                   |  58 kB  00:00:00     
(6/7): mysql80-community/x86_64/primary_db                                                                                                       |  62 kB  00:00:00     
(7/7): updates/7/x86_64/primary_db                                                                                                               | 4.2 MB  00:00:00     
Determining fastest mirrors
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-server.x86_64 0:8.0.16-1.el7 will be installed
--> Processing Dependency: mysql-community-common(x86-64) = 8.0.16-1.el7 for package: mysql-community-server-8.0.16-1.el7.x86_64
--> Processing Dependency: mysql-community-client(x86-64) >= 8.0.11 for package: mysql-community-server-8.0.16-1.el7.x86_64
--> Processing Dependency: libnuma.so.1(libnuma_1.2)(64bit) for package: mysql-community-server-8.0.16-1.el7.x86_64
--> Processing Dependency: libnuma.so.1(libnuma_1.1)(64bit) for package: mysql-community-server-8.0.16-1.el7.x86_64
--> Processing Dependency: libnuma.so.1()(64bit) for package: mysql-community-server-8.0.16-1.el7.x86_64
--> Running transaction check
---> Package mysql-community-client.x86_64 0:8.0.16-1.el7 will be installed
--> Processing Dependency: mysql-community-libs(x86-64) >= 8.0.11 for package: mysql-community-client-8.0.16-1.el7.x86_64
---> Package mysql-community-common.x86_64 0:8.0.16-1.el7 will be installed
---> Package numactl-libs.x86_64 0:2.0.9-7.el7 will be installed
--> Running transaction check
---> Package mariadb-libs.x86_64 1:5.5.56-2.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:8.0.16-1.el7 will be obsoleting
--> Running transaction check
---> Package mysql-community-libs-compat.x86_64 0:8.0.16-1.el7 will be obsoleting
---> Package postfix.x86_64 2:2.10.1-6.el7 will be updated
---> Package postfix.x86_64 2:2.10.1-7.el7 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================================================================================
 Package                                            Arch                          Version                                Repository                                Size
========================================================================================================================================================================
Installing:
 mysql-community-libs                               x86_64                        8.0.16-1.el7                           mysql80-community                        3.0 M
     replacing  mariadb-libs.x86_64 1:5.5.56-2.el7
 mysql-community-libs-compat                        x86_64                        8.0.16-1.el7                           mysql80-community                        2.1 M
     replacing  mariadb-libs.x86_64 1:5.5.56-2.el7
 mysql-community-server                             x86_64                        8.0.16-1.el7                           mysql80-community                        403 M
Installing for dependencies:
 mysql-community-client                             x86_64                        8.0.16-1.el7                           mysql80-community                         32 M
 mysql-community-common                             x86_64                        8.0.16-1.el7                           mysql80-community                        575 k
 numactl-libs                                       x86_64                        2.0.9-7.el7                            os                                        29 k
Updating for dependencies:
 postfix                                            x86_64                        2:2.10.1-7.el7                         os                                       2.4 M

Transaction Summary
========================================================================================================================================================================
Install  3 Packages (+3 Dependent packages)
Upgrade             ( 1 Dependent package)

Total download size: 443 M
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
warning: /var/cache/yum/x86_64/7/mysql80-community/packages/mysql-community-common-8.0.16-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY:44 ETA 
Public key for mysql-community-common-8.0.16-1.el7.x86_64.rpm is not installed
(1/7): mysql-community-common-8.0.16-1.el7.x86_64.rpm                                                                                            | 575 kB  00:00:01     
(2/7): mysql-community-libs-8.0.16-1.el7.x86_64.rpm                                                                                              | 3.0 MB  00:00:00     
(3/7): mysql-community-libs-compat-8.0.16-1.el7.x86_64.rpm                                                                                       | 2.1 MB  00:00:00     
(4/7): numactl-libs-2.0.9-7.el7.x86_64.rpm                                                                                                       |  29 kB  00:00:00     
(5/7): postfix-2.10.1-7.el7.x86_64.rpm                                                                                                           | 2.4 MB  00:00:00     
(6/7): mysql-community-client-8.0.16-1.el7.x86_64.rpm                                                                                            |  32 MB  00:00:20     
(7/7): mysql-community-server-8.0.16-1.el7.x86_64.rpm                                                                                            | 403 MB  00:00:48     
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                   8.7 MB/s | 443 MB  00:00:50     
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    : mysql80-community-release-el7-3.noarch (installed)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
  Installing : mysql-community-common-8.0.16-1.el7.x86_64                                                                                                           1/9 
  Installing : mysql-community-libs-8.0.16-1.el7.x86_64                                                                                                             2/9 
  Installing : mysql-community-client-8.0.16-1.el7.x86_64                                                                                                           3/9 
  Installing : mysql-community-libs-compat-8.0.16-1.el7.x86_64                                                                                                      4/9 
  Installing : numactl-libs-2.0.9-7.el7.x86_64                                                                                                                      5/9 
  Installing : mysql-community-server-8.0.16-1.el7.x86_64                                                                                                           6/9 
  Updating   : 2:postfix-2.10.1-7.el7.x86_64                                                                                                                        7/9 
  Cleanup    : 2:postfix-2.10.1-6.el7.x86_64                                                                                                                        8/9 
  Erasing    : 1:mariadb-libs-5.5.56-2.el7.x86_64                                                                                                                   9/9 
warning: file /usr/share/mysql/ukrainian/errmsg.sys: remove failed: No such file or directory
warning: file /usr/share/mysql/ukrainian: remove failed: No such file or directory
warning: file /usr/share/mysql/swedish/errmsg.sys: remove failed: No such file or directory
warning: file /usr/share/mysql/swedish: remove failed: No such file or directory
warning: file /usr/share/mysql/spanish/errmsg.sys: remove failed: No such file or directory
warning: file /usr/share/mysql/spanish: remove failed: No such file or directory
warning: file /usr/share/mysql/slovak/errmsg.sys: remove failed: No such file or directory
warning: file /usr/share/mysql/slovak: remove failed: No such file or directory
warning: file /usr/share/mysql/serbian/errmsg.sys: remove failed: No such file or directory
warning: file /usr/share/mysql/serbian: remove failed: No such file or directory
warning: file /usr/share/mysql/russian/errmsg.sys: remove failed: No such file or directory
warning: file /usr/share/mysql/russian: remove failed: No such file or directory
warning: file /usr/share/mysql/romanian/errmsg.sys: remove failed: No such file or directory
warning: file /usr/share/mysql/romanian: remove failed: No such file or directory
warning: file /usr/share/mysql/portuguese/errmsg.sys: remove failed: No such file or directory
warning: file /usr/share/mysql/portuguese: remove failed: No such file or directory
warning: file /usr/share/mysql/polish/errmsg.sys: remove failed: No such file or directory
warning: file /usr/share/mysql/polish: remove failed: No such file or directory
warning: file /usr/share/mysql/norwegian/errmsg.sys: remove failed: No such file or directory
warning: file /usr/share/mysql/norwegian-ny/errmsg.sys: remove failed: No such file or directory
warning: file /usr/share/mysql/norwegian-ny: remove failed: No such file or directory
warning: file /usr/share/mysql/norwegian: remove failed: No such file or directory
warning: file /usr/share/mysql/korean/errmsg.sys: remove failed: No such file or directory
warning: file /usr/share/mysql/korean: remove failed: No such file or directory
warning: file /usr/share/mysql/japanese/errmsg.sys: remove failed: No such file or directory
warning: file /usr/share/mysql/japanese: remove failed: No such file or directory
warning: file /usr/share/mysql/italian/errmsg.sys: remove failed: No such file or directory
warning: file /usr/share/mysql/italian: remove failed: No such file or directory
warning: file /usr/share/mysql/hungarian/errmsg.sys: remove failed: No such file or directory
warning: file /usr/share/mysql/hungarian: remove failed: No such file or directory
warning: file /usr/share/mysql/greek/errmsg.sys: remove failed: No such file or directory
warning: file /usr/share/mysql/greek: remove failed: No such file or directory
warning: file /usr/share/mysql/german/errmsg.sys: remove failed: No such file or directory
warning: file /usr/share/mysql/german: remove failed: No such file or directory
warning: file /usr/share/mysql/french/errmsg.sys: remove failed: No such file or directory
warning: file /usr/share/mysql/french: remove failed: No such file or directory
warning: file /usr/share/mysql/estonian/errmsg.sys: remove failed: No such file or directory
warning: file /usr/share/mysql/estonian: remove failed: No such file or directory
warning: file /usr/share/mysql/english/errmsg.sys: remove failed: No such file or directory
warning: file /usr/share/mysql/english: remove failed: No such file or directory
warning: file /usr/share/mysql/dutch/errmsg.sys: remove failed: No such file or directory
warning: file /usr/share/mysql/dutch: remove failed: No such file or directory
warning: file /usr/share/mysql/danish/errmsg.sys: remove failed: No such file or directory
warning: file /usr/share/mysql/danish: remove failed: No such file or directory
warning: file /usr/share/mysql/czech/errmsg.sys: remove failed: No such file or directory
warning: file /usr/share/mysql/czech: remove failed: No such file or directory
warning: file /usr/share/mysql/charsets/swe7.xml: remove failed: No such file or directory
warning: file /usr/share/mysql/charsets/macroman.xml: remove failed: No such file or directory
warning: file /usr/share/mysql/charsets/macce.xml: remove failed: No such file or directory
warning: file /usr/share/mysql/charsets/latin7.xml: remove failed: No such file or directory
warning: file /usr/share/mysql/charsets/latin5.xml: remove failed: No such file or directory
warning: file /usr/share/mysql/charsets/latin2.xml: remove failed: No such file or directory
warning: file /usr/share/mysql/charsets/latin1.xml: remove failed: No such file or directory
warning: file /usr/share/mysql/charsets/koi8u.xml: remove failed: No such file or directory
warning: file /usr/share/mysql/charsets/koi8r.xml: remove failed: No such file or directory
warning: file /usr/share/mysql/charsets/keybcs2.xml: remove failed: No such file or directory
warning: file /usr/share/mysql/charsets/hp8.xml: remove failed: No such file or directory
warning: file /usr/share/mysql/charsets/hebrew.xml: remove failed: No such file or directory
warning: file /usr/share/mysql/charsets/greek.xml: remove failed: No such file or directory
warning: file /usr/share/mysql/charsets/geostd8.xml: remove failed: No such file or directory
warning: file /usr/share/mysql/charsets/dec8.xml: remove failed: No such file or directory
warning: file /usr/share/mysql/charsets/cp866.xml: remove failed: No such file or directory
warning: file /usr/share/mysql/charsets/cp852.xml: remove failed: No such file or directory
warning: file /usr/share/mysql/charsets/cp850.xml: remove failed: No such file or directory
warning: file /usr/share/mysql/charsets/cp1257.xml: remove failed: No such file or directory
warning: file /usr/share/mysql/charsets/cp1256.xml: remove failed: No such file or directory
warning: file /usr/share/mysql/charsets/cp1251.xml: remove failed: No such file or directory
warning: file /usr/share/mysql/charsets/cp1250.xml: remove failed: No such file or directory
warning: file /usr/share/mysql/charsets/ascii.xml: remove failed: No such file or directory
warning: file /usr/share/mysql/charsets/armscii8.xml: remove failed: No such file or directory
warning: file /usr/share/mysql/charsets/README: remove failed: No such file or directory
warning: file /usr/share/mysql/charsets/Index.xml: remove failed: No such file or directory
warning: file /usr/share/mysql/charsets: remove failed: No such file or directory
warning: file /usr/share/mysql: remove failed: No such file or directory
warning: file /usr/lib64/mysql/plugin/mysql_clear_password.so: remove failed: No such file or directory
warning: file /usr/lib64/mysql/plugin/dialog.so: remove failed: No such file or directory
warning: file /usr/lib64/mysql/libmysqlclient.so.18.0.0: remove failed: No such file or directory
  Verifying  : numactl-libs-2.0.9-7.el7.x86_64                                                                                                                      1/9 
  Verifying  : mysql-community-client-8.0.16-1.el7.x86_64                                                                                                           2/9 
  Verifying  : mysql-community-libs-compat-8.0.16-1.el7.x86_64                                                                                                      3/9 
  Verifying  : 2:postfix-2.10.1-7.el7.x86_64                                                                                                                        4/9 
  Verifying  : mysql-community-libs-8.0.16-1.el7.x86_64                                                                                                             5/9 
  Verifying  : mysql-community-server-8.0.16-1.el7.x86_64                                                                                                           6/9 
  Verifying  : mysql-community-common-8.0.16-1.el7.x86_64                                                                                                           7/9 
  Verifying  : 1:mariadb-libs-5.5.56-2.el7.x86_64                                                                                                                   8/9 
  Verifying  : 2:postfix-2.10.1-6.el7.x86_64                                                                                                                        9/9 

Installed:
  mysql-community-libs.x86_64 0:8.0.16-1.el7          mysql-community-libs-compat.x86_64 0:8.0.16-1.el7          mysql-community-server.x86_64 0:8.0.16-1.el7         

Dependency Installed:
  mysql-community-client.x86_64 0:8.0.16-1.el7               mysql-community-common.x86_64 0:8.0.16-1.el7               numactl-libs.x86_64 0:2.0.9-7.el7              

Dependency Updated:
  postfix.x86_64 2:2.10.1-7.el7                                                                                                                                         

Replaced:
  mariadb-libs.x86_64 1:5.5.56-2.el7                                                                                                                                    

Complete!

  上面的安装过程有点长,可以看到它默认给我们安装了最新版本的mysql8,当然你也可以自己指定版本。另外它在安装时会去删掉原有的卸载残留,不过因为我们已经提前删掉了,所以会出现那一堆warnning提示删除卸载残留文件时没找到文件。

4、启动mysql

# service mysqld start
Redirecting to /bin/systemctl start mysqld.service
# service mysqld status
Redirecting to /bin/systemctl status mysqld.service
鈼[0m mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since Sat 2019-05-04 07:10:32 CST; 15s ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
  Process: 11678 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
 Main PID: 11772 (mysqld)
   Status: "SERVER_OPERATING"
   CGroup: /system.slice/mysqld.service
           鈹斺攢11772 /usr/sbin/mysqld

May 04 07:10:18 VM_0_17_centos systemd[1]: Starting MySQL Server...
May 04 07:10:32 VM_0_17_centos systemd[1]: Started MySQL Server.

5、找初始密码

# grep temporary password /var/log/mysqld.log 
2019-05-03T23:10:26.160286Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: c-uo(;XAc2FD

  这里的c-uo(;XAc2FD就是我的初始密码,复制它去登陆mysql。

6、登陆并修改密码

# mysql -uroot -p 
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.16

Copyright (c) 2000, 2019, 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> ALTER USER root@localhost IDENTIFIED BY Root123@;
Query OK, 0 rows affected (0.03 sec)

  这里说下密码规则:8位以上,大小写字母、数字和特殊字母。

7、创建个新库来用:

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)

mysql> create database test;
Query OK, 1 row affected (0.03 sec)

mysql> use test;
Database changed
mysql> show tables;
Empty set (0.00 sec)

8、重启mysql,使用新密码登陆,开始接入应用

# service mysqld restart
Redirecting to /bin/systemctl restart mysqld.service

  这里我是给安装mysql的机器自己用的,所以没有开发端口给远程。需要本地远程机器的话还得再设置一下,这里就不展开了。

 

CentOS下yum安装mysql

标签:OLE   col   大小写   redirect   upgrade   std   word   cache   cat   

原文地址:https://www.cnblogs.com/wuxun1997/p/10807466.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!