天堂1111 发表于 2018-9-29 13:26:53

Centos6快速安装mysql 5.6

一、检查系统是否安装其他版本的MYSQL数据# yum list installed | grep mysql  mysql-libs.x86_64       5.1.73-8.el6_8@anaconda-CentOS-201703281317.x86_64/6.9
  # yum -y remove mysql-libs.x86_64
  Loaded plugins: fastestmirror, security
  Setting up Remove Process
  Resolving Dependencies
  --> Running transaction check
  ---> Package mysql-libs.x86_64 0:5.1.73-8.el6_8 will be erased
  --> Processing Dependency: libmysqlclient.so.16()(64bit) for package: 2:postfix-2.6.6-8.el6.x86_64
  --> Processing Dependency: libmysqlclient.so.16(libmysqlclient_16)(64bit) for package: 2:postfix-2.6.6-8.el6.x86_64
  --> Processing Dependency: mysql-libs for package: 2:postfix-2.6.6-8.el6.x86_64
  --> Running transaction check
  ---> Package postfix.x86_64 2:2.6.6-8.el6 will be erased
  --> Processing Dependency: /usr/sbin/sendmail for package: cronie-1.4.4-16.el6_8.2.x86_64
  --> Running transaction check
  ---> Package cronie.x86_64 0:1.4.4-16.el6_8.2 will be erased
  --> Processing Dependency: cronie = 1.4.4-16.el6_8.2 for package: cronie-anacron-1.4.4-16.el6_8.2.x86_64
  --> Running transaction check
  ---> Package cronie-anacron.x86_64 0:1.4.4-16.el6_8.2 will be erased
  --> Processing Dependency: /etc/cron.d for package: sysstat-9.0.4-33.el6.x86_64
  --> Processing Dependency: /etc/cron.d for package: crontabs-1.10-33.el6.noarch
  --> Restarting Dependency Resolution with new changes.
  --> Running transaction check
  ---> Package crontabs.noarch 0:1.10-33.el6 will be erased
  ---> Package sysstat.x86_64 0:9.0.4-33.el6 will be erased
  --> Finished Dependency Resolution
  Dependencies Resolved
  ==================================================================================================================================================================
  Package                        Arch                     Version                               Repository                                                Size
  ==================================================================================================================================================================
  Removing:
  mysql-libs                     x86_64                   5.1.73-8.el6_8                        @anaconda-CentOS-201703281317.x86_64/6.9                   4.0 M
  Removing for dependencies:
  cronie                           x86_64                   1.4.4-16.el6_8.2                      @anaconda-CentOS-201703281317.x86_64/6.9                   174 k
  cronie-anacron                   x86_64                   1.4.4-16.el6_8.2                      @anaconda-CentOS-201703281317.x86_64/6.9                  43 k
  crontabs                         noarch                   1.10-33.el6                           @anaconda-CentOS-201703281317.x86_64/6.9                   2.4 k
  postfix                        x86_64                   2:2.6.6-8.el6                         @anaconda-CentOS-201703281317.x86_64/6.9                   9.7 M
  sysstat                        x86_64                   9.0.4-33.el6                        @anaconda-CentOS-201703281317.x86_64/6.9                   826 k
  Transaction Summary
  ==================================================================================================================================================================
  Remove      6 Package(s)

  Installed>  Downloading Packages:
  Running rpm_check_debug
  Running Transaction Test
  Transaction Test Succeeded
  Running Transaction
  Erasing    : sysstat-9.0.4-33.el6.x86_64                                                                                                                  1/6
  Erasing    : cronie-1.4.4-16.el6_8.2.x86_64                                                                                                               2/6
  Erasing    : cronie-anacron-1.4.4-16.el6_8.2.x86_64                                                                                                         3/6
  Erasing    : crontabs-1.10-33.el6.noarch                                                                                                                  4/6
  Erasing    : 2:postfix-2.6.6-8.el6.x86_64                                                                                                                   5/6
  Erasing    : mysql-libs-5.1.73-8.el6_8.x86_64                                                                                                               6/6
  Verifying: cronie-anacron-1.4.4-16.el6_8.2.x86_64                                                                                                         1/6
  Verifying: cronie-1.4.4-16.el6_8.2.x86_64                                                                                                               2/6
  Verifying: 2:postfix-2.6.6-8.el6.x86_64                                                                                                                   3/6
  Verifying: crontabs-1.10-33.el6.noarch                                                                                                                  4/6
  Verifying: sysstat-9.0.4-33.el6.x86_64                                                                                                                  5/6
  Verifying: mysql-libs-5.1.73-8.el6_8.x86_64                                                                                                               6/6
  Removed:
  mysql-libs.x86_64 0:5.1.73-8.el6_8
  Dependency Removed:
  cronie.x86_64 0:1.4.4-16.el6_8.2      cronie-anacron.x86_64 0:1.4.4-16.el6_8.2      crontabs.noarch 0:1.10-33.el6      postfix.x86_64 2:2.6.6-8.el6
  sysstat.x86_64 0:9.0.4-33.el6
  Complete!
二、安装及配置  # yum list installed | grep mysql
  # wget http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm
  --2018-04-23 01:23:56--http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm
  Resolving repo.mysql.com... 23.50.239.110
  Connecting to repo.mysql.com|23.50.239.110|:80... connected.
  HTTP request sent, awaiting response... 200 OK
  Length: 5824 (5.7K)
  Saving to: “mysql-community-release-el6-5.noarch.rpm”
  100%[========================================================================================================================>] 5,824       --.-K/s   in 0s
  2018-04-23 01:23:57 (190 MB/s) - “mysql-community-release-el6-5.noarch.rpm” saved
  # ll
  total 48
  -rw-------. 1 root root1139 Apr 19 23:22 anaconda-ks.cfg
  -rw-r--r--. 1 root root 21736 Apr 19 23:22 install.log
  -rw-r--r--. 1 root root5890 Apr 19 23:20 install.log.syslog
  -rw-r--r--. 1 root root5824 Nov 122015 mysql-community-release-el6-5.noarch.rpm
  # rpm -ivh mysql-community-release-el6-5.noarch.rpm
  Preparing...                ###########################################
  1:mysql-community-release###########################################
  # ll
  total 48
  -rw-------. 1 root root1139 Apr 19 23:22 anaconda-ks.cfg
  -rw-r--r--. 1 root root 21736 Apr 19 23:22 install.log
  -rw-r--r--. 1 root root5890 Apr 19 23:20 install.log.syslog
  -rw-r--r--. 1 root root5824 Nov 122015 mysql-community-release-el6-5.noarch.rpm
  # yum repolist all | grep mysql
  mysql-connectors-community      MySQL Connectors Community      enabled:    49
  mysql-connectors-community-source MySQL Connectors Community - So disabled
  mysql-tools-community             MySQL Tools Community         enabled:    61
  mysql-tools-community-source      MySQL Tools Community - Sourcedisabled
  mysql55-community               MySQL 5.5 Community Server      disabled
  mysql55-community-source          MySQL 5.5 Community Server - So disabled
  mysql56-community               MySQL 5.6 Community Server      enabled:   434
  mysql56-community-source          MySQL 5.6 Community Server - So disabled
  mysql57-community-dmr             MySQL 5.7 Community Server Deve disabled
  mysql57-community-dmr-source      MySQL 5.7 Community Server Deve disabled
安装MYSQL数据库  # yum install mysql-community-server -y
  Loaded plugins: fastestmirror, security
  Setting up Install Process
  Loading mirror speeds from cached hostfile
  * base: mirrors.tuna.tsinghua.edu.cn
  * extras: mirror.bit.edu.cn
  * updates: mirror.bit.edu.cn
  Resolving Dependencies
  --> Running transaction check
  ---> Package mysql-community-server.x86_64 0:5.6.40-2.el6 will be installed
  --> Processing Dependency: mysql-community-common(x86-64) = 5.6.40-2.el6 for package: mysql-community-server-5.6.40-2.el6.x86_64
  --> Processing Dependency: mysql-community-client(x86-64) >= 5.6.10 for package: mysql-community-server-5.6.40-2.el6.x86_64
  --> Processing Dependency: perl(DBI) for package: mysql-community-server-5.6.40-2.el6.x86_64
  --> Running transaction check
  ---> Package mysql-community-client.x86_64 0:5.6.40-2.el6 will be installed
  --> Processing Dependency: mysql-community-libs(x86-64) >= 5.6.10 for package: mysql-community-client-5.6.40-2.el6.x86_64
  ---> Package mysql-community-common.x86_64 0:5.6.40-2.el6 will be installed
  ---> Package perl-DBI.x86_64 0:1.609-4.el6 will be installed
  --> Running transaction check
  ---> Package mysql-community-libs.x86_64 0:5.6.40-2.el6 will be installed
  --> Finished Dependency Resolution
  Dependencies Resolved
  ==================================================================================================================================================================
  Package                                       Arch                        Version                               Repository                              Size
  ==================================================================================================================================================================
  Installing:
  mysql-community-server                        x86_64                        5.6.40-2.el6                        mysql56-community                         55 M
  Installing for dependencies:
  mysql-community-client                        x86_64                        5.6.40-2.el6                        mysql56-community                         18 M
  mysql-community-common                        x86_64                        5.6.40-2.el6                        mysql56-community                        308 k
  mysql-community-libs                        x86_64                        5.6.40-2.el6                        mysql56-community                        1.9 M
  perl-DBI                                    x86_64                        1.609-4.el6                           base                                     705 k
  Transaction Summary
  ==================================================================================================================================================================
  Install       5 Package(s)

  Total download>
  Installed>  Downloading Packages:
  (1/5): mysql-community-client-5.6.40-2.el6.x86_64.rpm                                                                                    |18 MB   00:33
  (2/5): mysql-community-common-5.6.40-2.el6.x86_64.rpm                                                                                    | 308 kB   00:00
  (3/5): mysql-community-libs-5.6.40-2.el6.x86_64.rpm                                                                                        | 1.9 MB   00:03
  (4/5): mysql-community-server-5.6.40-2.el6.x86_64.rpm                                                                                    |55 MB   02:55
  (5/5): perl-DBI-1.609-4.el6.x86_64.rpm                                                                                                   | 705 kB   00:01
  ------------------------------------------------------------------------------------------------------------------------------------------------------------------
  Total                                                                                                                           358 kB/s |75 MB   03:35

  warning: rpmts_HdrFromFdno: Header V3 DSA/SHA1 Signature, key>  Retrieving key from file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
  Importing GPG key 0x5072E1F5:

  Userid : MySQL>  Package: mysql-community-release-el6-5.noarch (installed)
  From   : file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

  warning: rpmts_HdrFromFdno: Header V3 RSA/SHA256 Signature, key>  Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
  Importing GPG key 0xC105B9DE:
  Userid : CentOS-6 Key (CentOS 6 Official Signing Key)
  Package: centos-release-6-9.el6.12.3.x86_64 (@anaconda-CentOS-201703281317.x86_64/6.9)
  From   : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
  Running rpm_check_debug
  Running Transaction Test
  Transaction Test Succeeded
  Running Transaction
  Warning: RPMDB>  Installing : mysql-community-common-5.6.40-2.el6.x86_64                                                                                                   1/5
  Installing : mysql-community-libs-5.6.40-2.el6.x86_64                                                                                                       2/5
  Installing : mysql-community-client-5.6.40-2.el6.x86_64                                                                                                   3/5
  Installing : perl-DBI-1.609-4.el6.x86_64                                                                                                                  4/5
  Installing : mysql-community-server-5.6.40-2.el6.x86_64                                                                                                   5/5
  Verifying: mysql-community-client-5.6.40-2.el6.x86_64                                                                                                   1/5
  Verifying: mysql-community-common-5.6.40-2.el6.x86_64                                                                                                   2/5
  Verifying: mysql-community-libs-5.6.40-2.el6.x86_64                                                                                                       3/5
  Verifying: mysql-community-server-5.6.40-2.el6.x86_64                                                                                                   4/5
  Verifying: perl-DBI-1.609-4.el6.x86_64                                                                                                                  5/5
  Installed:
  mysql-community-server.x86_64 0:5.6.40-2.el6
  Dependency Installed:
  mysql-community-client.x86_64 0:5.6.40-2.el6          mysql-community-common.x86_64 0:5.6.40-2.el6          mysql-community-libs.x86_64 0:5.6.40-2.el6
  perl-DBI.x86_64 0:1.609-4.el6
  Complete!
设置为开机启动(2、3、4都是on代表开机自动启动)# chkconfig --list | grep mysqld  mysqld         0:off1:off2:off3:on4:on5:on6:off
  # chkconfig mysqld on
  # chkconfig --list | grep mysqld
  mysqld         0:off1:off2:on3:on4:on5:on6:off
三、设置远程root  启动mysql
# service mysqld start设置root密码# mysql_secure_installation登陆root账号# mysql -uroot -p建立远程root用户mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'>mysql> flush privileges;
四、设置utf-8编码  查看mysql原本编码:
mysql> show variables like 'character%';设置编码# vi /etc/my.cnf如下(少补):https://common.cnblogs.com/images/copycode.gif
  
character-set-server=utf8
  
collation-server=utf8_general_ci
  
sql_mode='NO_ENGINE_SUBSTITUTION'
  
  
default-character-set = utf8
  

  

  
default-character-set = utf8
  

  

  

  
default-character-set = utf8
  

  

  

  
default-character-set = utf8
https://common.cnblogs.com/images/copycode.gif
  重启mysql
# service mysqld restart  再次查看编码:
https://common.cnblogs.com/images/copycode.gif
   # mysql -uroot -p  mysql> show variables like 'character%';
  +--------------------------+----------------------------+
  | Variable_name | Value |
  +--------------------------+----------------------------+
  | character_set_client | utf8 |
  | character_set_connection | utf8 |
  | character_set_database | utf8 |
  | character_set_filesystem | binary |
  | character_set_results | utf8 |
  | character_set_server | utf8 |
  | character_set_system | utf8 |
  | character_sets_dir | /usr/share/mysql/charsets/ |
  +--------------------------+----------------------------+
  8 rows in set (0.00 sec)
https://common.cnblogs.com/images/copycode.gif


页: [1]
查看完整版本: Centos6快速安装mysql 5.6