使用rpm 安裝mysql5.7.20

首先下載安裝包

mysql-community-client-5.7.20-1.el6.x86_64.rpm

mysql-community-devel-5.7.20-1.el6.x86_64.rpm

mysql-community-libs-5.7.20-1.el6.x86_64.rpm

mysql-community-server-5.7.20-1.el6.x86_64.rpm

mysql-community-common-5.7.20-1.el6.x86_64.rpm


必要的安裝需求:

yum install numactl
yum install libaio
yum install perl-Time-HiRes per-devel

安裝之前,需要卸載掉系統自帶的mysql-lib(版本低)

[root@host-192-168-14-59 ~]# rpm -qa | grep -i mysql
mysql-libs-5.1.73-8.el6_8.x86_64
[root@host-192-168-14-59 ~]# yum -y remove mysql-libs*
Loaded plugins: fastestmirror
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: 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
--> 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

Transaction Summary
=========================================================================================================
Remove        5 Package(s)

Installed size: 14 M
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Erasing    : cronie-anacron-1.4.4-16.el6_8.2.x86_64                                                1/5 
  Erasing    : crontabs-1.10-33.el6.noarch                                                           2/5 
  Erasing    : cronie-1.4.4-16.el6_8.2.x86_64                                                        3/5 
  Erasing    : 2:postfix-2.6.6-8.el6.x86_64                                                          4/5 
  Erasing    : mysql-libs-5.1.73-8.el6_8.x86_64                                                      5/5 
  Verifying  : 2:postfix-2.6.6-8.el6.x86_64                                                          1/5 
  Verifying  : crontabs-1.10-33.el6.noarch                                                           2/5 
  Verifying  : cronie-anacron-1.4.4-16.el6_8.2.x86_64                                                3/5 
  Verifying  : cronie-1.4.4-16.el6_8.2.x86_64                                                        4/5 
  Verifying  : mysql-libs-5.1.73-8.el6_8.x86_64                                                      5/5 

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                           

Complete!


安裝mysql(按順序安裝)

[root@host-192-168-14-59 local]# rpm -ivh mysql-community-common-5.7.20-1.el6.x86_64.rpm 
warning: mysql-community-common-5.7.20-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                ########################################### [100%]
   1:mysql-community-common ########################################### [100%]
[root@host-192-168-14-59 local]# rpm -ivh mysql-community-libs-5.7.20-1.el6.x86_64.rpm 
warning: mysql-community-libs-5.7.20-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                ########################################### [100%]
   1:mysql-community-libs   ########################################### [100%]
[root@host-192-168-14-59 local]# rpm -ivh mysql-community-client-5.7.20-1.el6.x86_64.rpm 
warning: mysql-community-client-5.7.20-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                ########################################### [100%]
   1:mysql-community-client ########################################### [100%]

rpm -ivh mysql-community-server-5.7.20-1.el6.x86_64.rpm 
warning: mysql-community-server-5.7.20-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                ########################################### [100%]
   1:mysql-community-server ########################################### [100%]

rpm -ivh mysql-community-devel-5.7.20-1.el6.x86_64.rpm 
warning: mysql-community-devel-5.7.20-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                ########################################### [100%]
   1:mysql-community-devel  ########################################### [100%]


啓動mysql服務:


[root@host-192-168-14-59 local]# service mysqld start
Initializing MySQL database:                               [  OK  ]
Starting mysqld:                                           [  OK  ]

查看是否啓動成功:

[root@host-192-168-14-59 local]# ps -ef | grep mysqld
root      7482     1  0 10:41 pts/0    00:00:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --socket=/var/lib/mysql/mysql.sock --pid-file=/var/run/mysqld/mysqld.pid --basedir=/usr --user=mysql
mysql     7676  7482  0 10:41 pts/0    00:00:00 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --log-error=/var/log/mysqld.log --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/lib/mysql/mysql.sock
root      7717  7212  0 10:44 pts/0    00:00:00 grep mysqld

在 etc/my.cnf 裏面是mysql的默認設置

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html

[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

在查看/var/log/mysqld.log時我的出現了沒有初始密碼

[root@host-192-168-14-59 etc]# cat /var/log/mysqld.log | more
2017-11-14T02:40:47.203990Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use -
-explicit_defaults_for_timestamp server option (see documentation for more details).
2017-11-14T02:40:51.998640Z 0 [Warning] InnoDB: New log files created, LSN=45790
2017-11-14T02:40:52.969175Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2017-11-14T02:40:53.166248Z 0 [Warning] No existing UUID has been found, so we assume that this is the fi
rst time that this server has been started. Generating a new UUID: 3ba2863b-c8e5-11e7-b4a2-fa163ee2ac35.
2017-11-14T02:40:53.210276Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' c
annot be opened.
2017-11-14T02:40:53.211271Z 1 [Note] A temporary password is generated for root@localhost: PSiP4dTtRI!L
2017-11-14T02:41:32.352593Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use -
-explicit_defaults_for_timestamp server option (see documentation for more details).
2017-11-14T02:41:32.354844Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.20) starting as process 7676 ...
2017-11-14T02:41:32.358170Z 0 [Note] InnoDB: PUNCH HOLE support available
2017-11-14T02:41:32.358186Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2017-11-14T02:41:32.358190Z 0 [Note] InnoDB: Uses event mutexes
2017-11-14T02:41:32.358195Z 0 [Note] InnoDB: GCC builtin __sync_synchronize() is used for memory barrier
2017-11-14T02:41:32.358198Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3
2017-11-14T02:41:32.358201Z 0 [Note] InnoDB: Using Linux native AIO
2017-11-14T02:41:32.358367Z 0 [Note] InnoDB: Number of pools: 1
2017-11-14T02:41:32.358441Z 0 [Note] InnoDB: Using CPU crc32 instructions
2017-11-14T02:41:32.359898Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, 
chunk size = 128M
2017-11-14T02:41:32.367600Z 0 [Note] InnoDB: Completed initialization of buffer pool
2017-11-14T02:41:32.369931Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thr
ead priority can be changed. See the man page of setpriority().
2017-11-14T02:41:32.382576Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2017-11-14T02:41:32.500196Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2017-11-14T02:41:32.500251Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing th
e file full; Please wait ...
2017-11-14T02:41:33.066706Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2017-11-14T02:41:33.067368Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(
s) are active.
2017-11-14T02:41:33.067378Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2017-11-14T02:41:33.068226Z 0 [Note] InnoDB: Waiting for purge to start
2017-11-14T02:41:33.118411Z 0 [Note] InnoDB: 5.7.20 started; log sequence number 2566777
2017-11-14T02:41:33.119172Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2017-11-14T02:41:33.119343Z 0 [Note] Plugin 'FEDERATED' is disabled.
2017-11-14T02:41:33.120796Z 0 [Note] InnoDB: Buffer pool(s) load completed at 171114 10:41:33
2017-11-14T02:41:33.125408Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. 
Trying to enable SSL support using them.
2017-11-14T02:41:33.125592Z 0 [Warning] CA certificate ca.pem is self signed.
2017-11-14T02:41:33.126907Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
2017-11-14T02:41:33.127197Z 0 [Note] IPv6 is available.
2017-11-14T02:41:33.127205Z 0 [Note]   - '::' resolves to '::';
2017-11-14T02:41:33.127216Z 0 [Note] Server socket created on IP: '::'.
2017-11-14T02:41:33.257110Z 0 [Note] Event Scheduler: Loaded 0 events
2017-11-14T02:41:33.257272Z 0 [Note] /usr/sbin/mysqld: ready for connections.
Version: '5.7.20'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  MySQL Community Server (GPL)
2017-11-14T02:41:33.257285Z 0 [Note] Executing 'SELECT * FROM INFORMATION_SCHEMA.TABLES;' to get a list of tables using the deprecated partition engine. You may use the startup option '--disable-partition-engine-check' to skip this chec
k. 
2017-11-14T02:41:33.257292Z 0 [Note] Beginning of list of non-natively partitioned tables
2017-11-14T02:41:33.266922Z 0 [Note] End of list of non-natively partitioned tables
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2017-11-14T02:41:34.066307Z 3 [Note] Access denied for user 'UNKNOWN_MYSQL_USER'@'localhost' (using password: NO)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++



解決辦法.

/etc/init.d/mysql stop  #停止mysql服務,/etc/init.d/mysqld stop 現在是這個命令

/usr/bin/mysqld_safe --skip-grant-tables 跳過命令啓動

再開一個ssh

[root@host-192-168-14-59 ~]# mysql

mysql> use mysql

// mysql>update user set password=password("123456") where user="root"; #在5.7中已經沒有password這個字段了,password字段改成了

authentication_string
所以現在是用:

mysql>update mysql.user set authentication_string=password('123456') where user='root' ;  #賬號 root  密碼 123456

mysql>flush privileges;

mysql>exit

然後:

[root@host-192-168-14-59 ~]# ps -A | grep mysql
 7775 pts/0    00:00:00 mysqld_safe
 7913 pts/0    00:00:00 mysqld
[root@host-192-168-14-59 ~]# kill -9 7775 7913

正常啓動 MySQL:/etc/init.d/mysqld start

mysql -u root -p           

OK



ps:

在進到mysql裏面後,第一次操作的時候出現:

ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
意思是需要重置你的初始密碼,如果你只是想設置一個簡單的密碼自己使用,會出現:

mysql> SET PASSWORD = PASSWORD('123456');
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

這是需要調整一個全局變量:

mysql> set global validate_password_policy=0;

validate_password_policy有以下取值:

Policy Tests Performed
0 or LOW Length
1 or MEDIUM Length; numeric, lowercase/uppercase, and special characters
2 or STRONG Length; numeric, lowercase/uppercase, and special characters; dictionary file

mysql> SET PASSWORD = PASSWORD('12345678');
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> ALTER USER 'root'@'localhost'PASSWORD EXPIRE NEVER;
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> exit
Bye

這樣退出,再進就好了.


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章