mysql-5.7.18安装
下载 mysql-5.7.18-1.el5.x86_64.rpm-bundle.tar
https://downloads.mysql.com/archives/community/
Please note that these are old versions. New releases will have recent bug fixes and features!
To download the latest release of MySQL Community Server, please visit MySQL Downloads.
Product Version:
5.7.18
Operating System:
Red Hat Enterprise Linux / Oracle Linux
OS Version:
Red Hat Enterprise Linux 5 / Oracle Linux 5 (x86, 64-bit)
RPM Bundle Mar 20, 2017 653.1M
Download
(mysql-5.7.18-1.el5.x86_64.rpm-bundle.tar) MD5: 42d86f6cc2c528701f4807bb3d5b2d5b | Signature
mysql-5.7.18是最后的一个支持Red Hat Enterprise Linux 5的。
-------------------------------------
解压
[root@localhost mysql]# ll -h
total 654M
-rw-r--r-- 1 7155 31415 41K Mar 20 2017 mysql-5.7.18-1.el5.x86_64.rpm
-rw-r--r-- 1 7155 31415 32M Mar 20 2017 mysql-community-client-5.7.18-1.el5.x86_64.rpm
-rw-r--r-- 1 7155 31415 814K Mar 20 2017 mysql-community-common-5.7.18-1.el5.x86_64.rpm
-rw-r--r-- 1 7155 31415 5.4M Mar 20 2017 mysql-community-devel-5.7.18-1.el5.x86_64.rpm
-rw-r--r-- 1 7155 31415 54M Mar 20 2017 mysql-community-embedded-5.7.18-1.el5.x86_64.rpm
-rw-r--r-- 1 7155 31415 185M Mar 20 2017 mysql-community-embedded-devel-5.7.18-1.el5.x86_64.rpm
-rw-r--r-- 1 7155 31415 2.9M Mar 20 2017 mysql-community-libs-5.7.18-1.el5.x86_64.rpm
-rw-r--r-- 1 7155 31415 2.2M Mar 20 2017 mysql-community-libs-compat-5.7.18-1.el5.x86_64.rpm
-rw-r--r-- 1 7155 31415 228M Mar 20 2017 mysql-community-server-5.7.18-1.el5.x86_64.rpm
-rw-r--r-- 1 7155 31415 146M Mar 20 2017 mysql-community-test-5.7.18-1.el5.x86_64.rpm
安装
[root@localhost mysql]# rpm -ivh mysql-community-common-5.7.18-1.el5.x86_64.rpm
warning: mysql-community-common-5.7.18-1.el5.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 5072e1f5
error: Failed dependencies:
mysql >= 5.7.9 is needed by mysql-community-common-5.7.18-1.el5.x86_64
[root@localhost mysql]# rpm -ivh mysql-community-common-5.7.18-1.el5.x86_64.rpm --nodeps
warning: mysql-community-common-5.7.18-1.el5.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 5072e1f5
Preparing... ########################################### [100%]
1:mysql-community-common ########################################### [100%]
[root@localhost mysql]#
[root@localhost mysql]# rpm -ivh mysql-community-libs-5.7.18-1.el5.x86_64.rpm
warning: mysql-community-libs-5.7.18-1.el5.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 5072e1f5
Preparing... ########################################### [100%]
1:mysql-community-libs ########################################### [100%]
/sbin/ldconfig: /usr/local/nmapDir/libpcap.so.1 is not a symbolic link
[root@localhost mysql]#
[root@localhost mysql]# rpm -ivh mysql-community-client-5.7.18-1.el5.x86_64.rpm
warning: mysql-community-client-5.7.18-1.el5.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 5072e1f5
Preparing... ########################################### [100%]
1:mysql-community-client ########################################### [100%]
[root@localhost mysql]#
[root@localhost mysql]# rpm -ivh mysql-community-server-5.7.18-1.el5.x86_64.rpm
warning: mysql-community-server-5.7.18-1.el5.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 5072e1f5
Preparing... ########################################### [100%]
1:mysql-community-server ########################################### [100%]
[root@localhost mysql]#
-------------------------------------
安装好后
初始化数据库
初始化后会在/var/log/mysqld.log生成随机密码
[root@localhost mysql]# mysqld --initialize
[root@localhost mysql]# cat /var/log/mysqld.log
2021-11-22T02:34:00.763890Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2021-11-22T02:34:02.918078Z 0 [Warning] InnoDB: New log files created, LSN=45790
2021-11-22T02:34:03.886998Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2021-11-22T02:34:03.892887Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: a8831d6e-4b3c-11ec-b603-000c2962a9da.
2021-11-22T02:34:03.894530Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2021-11-22T02:34:03.896102Z 1 [Note] A temporary password is generated for root@localhost: #pCZIcy+b9D1
[root@localhost mysql]#
密码
#pCZIcy+b9D1
-------------------------------------
修改mysql数据库目录的所属用户及其所属组,然后启动mysql数据库
[root@VM_0_16_centos mysql5.7.23]# chown mysql:mysql /var/lib/mysql -R
[root@VM_0_16_centos mysql5.7.23]# systemctl start mysqld.service
[root@VM_0_16_centos mysql5.7.23]# systemctl status mysqld.service
如果没有systemctl
[root@localhost mysql]# service mysqld start
Starting mysqld: [ OK ]
[root@localhost mysql]# service mysqld status
mysqld (pid 5844) is running...
[root@localhost mysql]#
-------------------------------------
mysql -uroot -p
手动输入密码
#pCZIcy+b9D1
修改密码为123456
mysql> alter user 'root'@'localhost' identified by '123456';
Query OK, 0 rows affected (0.00 sec)
-- 密码永不过期
ALTER USER 'root'@'localhost' IDENTIFIED BY '123456' PASSWORD EXPIRE NEVER;
-------------------------------------
允许外面连接
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
FLUSH PRIVILEGES;
grant all privileges on *.* to 'root'@'%' identified by '123456';
mysql>
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
Query OK, 0 rows affected, 1 warning (0.03 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
mysql>
mysql> grant all privileges on *.* to 'root'@'%' identified by '123456';
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql>
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123456' PASSWORD EXPIRE NEVER;
Query OK, 0 rows affected (0.00 sec)
mysql> quit
Bye
[root@localhost mysql]#
-------------------------------------
现在就可以用Navicat连接mysql5.7。
===============================================================================
报错
Incorrect datetime value: '0000-00-00 00:00:00' for column 'start_time' at row 5 With statement:
set global sql_mode='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
mysql> show variables like 'sql_mode';
+---------------+-------------------------------------------------------------------------------------------------------------------------------------------+
| Variable_name | Value |
+---------------+-------------------------------------------------------------------------------------------------------------------------------------------+
| sql_mode | ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION |
+---------------+-------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
使用 vi /etc/my.cnf
把sql_mode查到的结果中,NO_ZERO_IN_DATE,NO_ZERO_DATE,去掉,写进sql_mode变量,加/etc/my.cnf后面。
sql_mode='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'
重启mysqld服务
[root@localhost mysql]# service mysqld restart
Stopping mysqld: [ OK ]
Starting mysqld: [ OK ]
mysql> show variables like 'sql_mode';
+---------------+--------------------------------------------------------------------------------------------------------------+
| Variable_name | Value |
+---------------+--------------------------------------------------------------------------------------------------------------+
| sql_mode | ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION |
+---------------+--------------------------------------------------------------------------------------------------------------+
1 row in set (0.01 sec)
mysql>
===============================================================================
报错
[Err] [Dtf] 1153 - Got a packet bigger than 'max_allowed_packet' bytes With statement:
mysql> show variables like 'net_buffer_length';
+-------------------+-------+
| Variable_name | Value |
+-------------------+-------+
| net_buffer_length | 16384 |
+-------------------+-------+
1 row in set (0.00 sec)
mysql> show variables like 'max_allowed_packet';
+--------------------+---------+
| Variable_name | Value |
+--------------------+---------+
| max_allowed_packet | 4194304 |
+--------------------+---------+
1 row in set (0.00 sec)
mysql>
---------------------------------------------
mysql> set global net_buffer_length=1000000;
Query OK, 0 rows affected, 1 warning (0.02 sec)
mysql> set global max_allowed_packet=1000000000;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql>
mysql> quit
Bye
[root@localhost mysql]#
mysql> show variables like 'max_allowed_packet';
+--------------------+-----------+
| Variable_name | Value |
+--------------------+-----------+
| max_allowed_packet | 999999488 |
+--------------------+-----------+
1 row in set (0.04 sec)
mysql> show variables like 'net_buffer_length';
+-------------------+--------+
| Variable_name | Value |
+-------------------+--------+
| net_buffer_length | 999424 |
+-------------------+--------+
1 row in set (0.00 sec)
mysql>