MySQL 5.7安装、升级笔记分享:

卸载当前的 MySQL

查看当前 MySQL 版本:

1
2
[root@coderknock ~]# mysql -V
mysql Ver 14.14 Distrib 5.1.73, for redhat-linux-gnu (i386) using readline 5.1

停止 MySQL 服务

1
2
[root@coderknock ~]# service mysqld stop
Stopping mysqld:      [ OK ]

备份数据【数据不重要可以忽略】

备份数据库,升级MySQL通常不会丢失数据,但保险起见,我们需要做这一步。输入命令:

[root@coderknock ~]# mysqldump -u xxx -h xxx -P 3306 -p --all-databases > databases.sql

卸载旧版本 MySQL

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
[root@coderknock ~]# yum remove mysql mysql-*
Loaded plugins: security
Setting up Remove Process
Resolving Dependencies
--> Running transaction check
---> Package mysql.i686 0:5.1.73-7.el6 will be erased
---> Package mysql-libs.i686 0:5.1.73-7.el6 will be erased
--> Processing Dependency: libmysqlclient.so.16 for package: 2:postfix-2.6.6-6.el6_7.1.i686
--> Processing Dependency: libmysqlclient.so.16 for package: perl-DBD-MySQL-4.013-3.el6.i686
--> Processing Dependency: libmysqlclient.so.16(libmysqlclient_16) for package: 2:postfix-2.6.6-6.el6_7.1.i686
--> Processing Dependency: libmysqlclient.so.16(libmysqlclient_16) for package: perl-DBD-MySQL-4.013-3.el6.i686
--> Processing Dependency: mysql-libs for package: 2:postfix-2.6.6-6.el6_7.1.i686
---> Package mysql-server.i686 0:5.1.73-7.el6 will be erased
--> Running transaction check
---> Package perl-DBD-MySQL.i686 0:4.013-3.el6 will be erased
---> Package postfix.i686 2:2.6.6-6.el6_7.1 will be erased
--> Processing Dependency: /usr/sbin/sendmail for package: cronie-1.4.4-16.el6_8.2.i686
--> Processing Dependency: /usr/sbin/sendmail for package: redhat-lsb-core-4.0-7.el6.centos.i686
--> Running transaction check
---> Package cronie.i686 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.i686
---> Package redhat-lsb-core.i686 0:4.0-7.el6.centos will be erased
--> Running transaction check
---> Package cronie-anacron.i686 0:1.4.4-16.el6_8.2 will be erased
--> Processing Dependency: /etc/cron.d for package: crontabs-1.10-33.el6.noarch
--> Processing Dependency: /etc/cron.d for package: sysstat-9.0.4-31.el6.i686
--> Restarting Dependency Resolution with new changes.
--> Running transaction check
---> Package crontabs.noarch 0:1.10-33.el6 will be erased
---> Package sysstat.i686 0:9.0.4-31.el6 will be erased
--> Finished Dependency Resolution
 
Dependencies Resolved
 
=======================================================================================================================================================================================================
 Package     Arch    Version     Repository        Size
=======================================================================================================================================================================================================
Removing:
 mysql     i686    5.1.73-7.el6     @base        2.3 M
 mysql-libs     i686    5.1.73-7.el6     @base        3.9 M
 mysql-server    i686    5.1.73-7.el6     @base        24 M
Removing for dependencies:
 cronie     i686    1.4.4-16.el6_8.2    @updates        169 k
 cronie-anacron    i686    1.4.4-16.el6_8.2    @updates        38 k
 crontabs     noarch    1.10-33.el6     @anaconda-CentOS-201311291201.i386/6.5    2.4 k
 perl-DBD-MySQL    i686    4.013-3.el6     @base        341 k
 postfix     i686    2:2.6.6-6.el6_7.1    @base        9.3 M
 redhat-lsb-core    i686    4.0-7.el6.centos    @anaconda-CentOS-201311291201.i386/6.5    22 k
 sysstat     i686    9.0.4-31.el6     @base        804 k
 
Transaction Summary
=======================================================================================================================================================================================================
Remove 10 Package(s)
 
Installed size: 41 M
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
 Erasing : mysql-server-5.1.73-7.el6.i686                   1/10
warning: /var/log/mysqld.log saved as /var/log/mysqld.log.rpmsave
 Erasing : redhat-lsb-core-4.0-7.el6.centos.i686                  2/10
/var/tmp/rpm-tmp.Y5QGjy: line 1: lsb_release: command not found
 Erasing : mysql-5.1.73-7.el6.i686                    3/10
 Erasing : perl-DBD-MySQL-4.013-3.el6.i686                   4/10
 Erasing : sysstat-9.0.4-31.el6.i686                    5/10
 Erasing : crontabs-1.10-33.el6.noarch                   6/10
 Erasing : cronie-anacron-1.4.4-16.el6_8.2.i686                  7/10
 Erasing : cronie-1.4.4-16.el6_8.2.i686                   8/10
 Erasing : 2:postfix-2.6.6-6.el6_7.1.i686                   9/10
 Erasing : mysql-libs-5.1.73-7.el6.i686                   10/10
 Verifying : redhat-lsb-core-4.0-7.el6.centos.i686                  1/10
 Verifying : perl-DBD-MySQL-4.013-3.el6.i686                   2/10
 Verifying : mysql-server-5.1.73-7.el6.i686                   3/10
 Verifying : crontabs-1.10-33.el6.noarch                   4/10
 Verifying : sysstat-9.0.4-31.el6.i686                    5/10
 Verifying : cronie-anacron-1.4.4-16.el6_8.2.i686                  6/10
 Verifying : cronie-1.4.4-16.el6_8.2.i686                   7/10
 Verifying : mysql-libs-5.1.73-7.el6.i686                   8/10
 Verifying : mysql-5.1.73-7.el6.i686                    9/10
 Verifying : 2:postfix-2.6.6-6.el6_7.1.i686                   10/10
 
Removed:
 mysql.i686 0:5.1.73-7.el6     mysql-libs.i686 0:5.1.73-7.el6     mysql-server.i686 0:5.1.73-7.el6    
 
Dependency Removed:
 cronie.i686 0:1.4.4-16.el6_8.2  cronie-anacron.i686 0:1.4.4-16.el6_8.2 crontabs.noarch 0:1.10-33.el6 perl-DBD-MySQL.i686 0:4.013-3.el6 postfix.i686 2:2.6.6-6.el6_7.1
 redhat-lsb-core.i686 0:4.0-7.el6.centos sysstat.i686 0:9.0.4-31.el6 
 
Complete!

这样就卸载完成了,为了保险起见我们检查一下系统中是否还有 MySQL 相关内容没有删除干净

1
2
[root@coderknock ~]# yum list installed | grep mysql
[root@coderknock ~]#

上面的情况是没有未删除部分,如果有的话可通过下面的命令删除:

[root@coderknock ~]# yum remove mysql-libs

下载最新版本的 MySQL

查看系统配置信息选择对应 MySQL 包

1
2
[root@coderknock ~]# uname -r
3.10.104-1.el6.elrepo.i686

在浏览器打开 sohu提供的MySQL 镜像(官网速度太慢)

然后根据自己系统配置选择对应的 rpm 包,右键复制文件链接,我的选择如下:

下载并解压

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Resolving mirrors.sohu.com... 119.188.36.70
Connecting to mirrors.sohu.com|119.188.36.70|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 448163840 (427M) [application/octet-stream]
Saving to: “mysql-5.7.17-1.el6.i686.rpm-bundle.tar”
 
100%[=============================================================================================================================================================>] 448,163,840 9.98M/s in 45s
 
2017-01-06 22:47:00 (9.54 MB/s) - “mysql-5.7.17-1.el6.i686.rpm-bundle.tar” saved [448163840/448163840]
[root@coderknock ~]# tar xvf mysql-5.7.17-1.el6.i686.rpm-bundle.tar
mysql-community-libs-compat-5.7.17-1.el6.i686.rpm
mysql-community-client-5.7.17-1.el6.i686.rpm
mysql-community-embedded-devel-5.7.17-1.el6.i686.rpm
mysql-community-devel-5.7.17-1.el6.i686.rpm
mysql-community-common-5.7.17-1.el6.i686.rpm
mysql-community-test-5.7.17-1.el6.i686.rpm
mysql-community-embedded-5.7.17-1.el6.i686.rpm
mysql-community-libs-5.7.17-1.el6.i686.rpm
mysql-community-server-5.7.17-1.el6.i686.rpm

安装及配置

安装 rpm 【有依赖关系,请按下面的步骤安装,搜索 [root@coderknock ~]# 可跳过安装日志直接查看相关命令】

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
[root@coderknock ~]# yum localinstall mysql-community-common-5.7.17-1.el6.i686.rpm
Loaded plugins: security
Setting up Local Package Process
Examining mysql-community-common-5.7.17-1.el6.i686.rpm: mysql-community-common-5.7.17-1.el6.i686
Marking mysql-community-common-5.7.17-1.el6.i686.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-common.i686 0:5.7.17-1.el6 will be installed
--> Finished Dependency Resolution
 
Dependencies Resolved
 
=======================================================================================================================================================================================================
 Package      Arch    Version     Repository        Size
=======================================================================================================================================================================================================
Installing:
 mysql-community-common    i686    5.7.17-1.el6    /mysql-community-common-5.7.17-1.el6.i686    2.5 M
 
Transaction Summary
=======================================================================================================================================================================================================
Install 1 Package(s)
 
Total size: 2.5 M
Installed size: 2.5 M
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
 Installing : mysql-community-common-5.7.17-1.el6.i686                  1/1
 Verifying : mysql-community-common-5.7.17-1.el6.i686                  1/1
 
Installed:
 mysql-community-common.i686 0:5.7.17-1.el6                   
 
Complete!
[root@coderknock ~]# yum localinstall mysql-community-libs-5.7.17-1.el6.i686.rpm
Loaded plugins: security
Setting up Local Package Process
Examining mysql-community-libs-5.7.17-1.el6.i686.rpm: mysql-community-libs-5.7.17-1.el6.i686
Marking mysql-community-libs-5.7.17-1.el6.i686.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-libs.i686 0:5.7.17-1.el6 will be installed
--> Finished Dependency Resolution
 
Dependencies Resolved
 
=======================================================================================================================================================================================================
 Package      Arch    Version     Repository        Size
=======================================================================================================================================================================================================
Installing:
 mysql-community-libs    i686    5.7.17-1.el6    /mysql-community-libs-5.7.17-1.el6.i686    7.8 M
 
Transaction Summary
=======================================================================================================================================================================================================
Install 1 Package(s)
 
Total size: 7.8 M
Installed size: 7.8 M
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
 Installing : mysql-community-libs-5.7.17-1.el6.i686                  1/1
 Verifying : mysql-community-libs-5.7.17-1.el6.i686                  1/1
 
Installed:
 mysql-community-libs.i686 0:5.7.17-1.el6                   
 
Complete!
[root@coderknock ~]# yum localinstall mysql-community-client-5.7.17-1.el6.i686.rpm
Loaded plugins: security
Setting up Local Package Process
Examining mysql-community-client-5.7.17-1.el6.i686.rpm: mysql-community-client-5.7.17-1.el6.i686
Marking mysql-community-client-5.7.17-1.el6.i686.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-client.i686 0:5.7.17-1.el6 will be installed
--> Finished Dependency Resolution
 
Dependencies Resolved
 
=======================================================================================================================================================================================================
 Package      Arch    Version     Repository        Size
=======================================================================================================================================================================================================
Installing:
 mysql-community-client    i686    5.7.17-1.el6    /mysql-community-client-5.7.17-1.el6.i686    87 M
 
Transaction Summary
=======================================================================================================================================================================================================
Install 1 Package(s)
 
Total size: 87 M
Installed size: 87 M
Is this ok [y/N]: ^[[A^Hy
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
 Installing : mysql-community-client-5.7.17-1.el6.i686                  1/1
 Verifying : mysql-community-client-5.7.17-1.el6.i686                  1/1
 
Installed:
 mysql-community-client.i686 0:5.7.17-1.el6                   
 
Complete!
[root@coderknock ~]# yum localinstall mysql-community-server-5.7.17-1.el6.i686.rpm
Loaded plugins: security
Setting up Local Package Process
Examining mysql-community-server-5.7.17-1.el6.i686.rpm: mysql-community-server-5.7.17-1.el6.i686
Marking mysql-community-server-5.7.17-1.el6.i686.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-server.i686 0:5.7.17-1.el6 will be installed
--> Finished Dependency Resolution
 
Dependencies Resolved
 
=======================================================================================================================================================================================================
 Package      Arch    Version     Repository        Size
=======================================================================================================================================================================================================
Installing:
 mysql-community-server    i686    5.7.17-1.el6    /mysql-community-server-5.7.17-1.el6.i686    695 M
 
Transaction Summary
=======================================================================================================================================================================================================
Install 1 Package(s)
 
Total size: 695 M
Installed size: 695 M
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
 Installing : mysql-community-server-5.7.17-1.el6.i686                  1/1
 Verifying : mysql-community-server-5.7.17-1.el6.i686                  1/1
 
Installed:
 mysql-community-server.i686 0:5.7.17-1.el6                   
 
Complete!

配置

查看版本

1
2
[root@coderknock ~]# mysql -V
mysql Ver 14.14 Distrib 5.7.17, for Linux (i686) using EditLine wrapper

启动 MySQL

1
2
3
[root@coderknock ~]# service mysqld start
MySQL Daemon failed to start.
Starting mysqld:   [FAILED]

上面的情况说明启动失败,这是因为经过上面的步骤,MySQL 最新版已经安装到我们的系统了,但这是还没有初始化数据,所以导致无法启动。

初始化数据库

[root@coderknock ~]# mysqld --initialize

如果遇到错误如下:

2017-01-06T14:53:08.889803Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-01-06T14:53:08.892190Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.
2017-01-06T14:53:08.892475Z 0 [ERROR] Aborting

可以运行以下命令【无需再执行 mysqld --initialize】:

1
2
3
4
5
[root@coderknock ~]# rm -rf /var/lib/mysql
[root@coderknock ~]# service mysqld start
Initializing MySQL database:  [ OK ]
Installing validate password plugin: [ OK ]
Starting mysqld:   [ OK ]

这样我们就启动了 MySQL 服务

MySQL 无法登陆的解决办法

登录时我遇到了一些问题:

1
2
3
[root@coderknock ~]# mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

这是因较新版本的 MySQL 因为安全的考虑,会设置默认密码

1
2
[root@coderknock ~]# grep 'temporary password' /var/log/mysqld.log
2017-01-06T14:53:33.490540Z 1 [Note] A temporary password is generated for root@localhost: Ei(GLix_p6/1

这样就找到了密码,如果上面方法不可行可以看看是否有 /root/.mysql_secret 文件

或者通过以下方法直接修改密码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
[root@coderknock ~]# service mysqld stop
Stopping mysqld:      [ OK ]
[root@coderknock ~]# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
[1] 14208
[root@coderknock ~]# 2017-01-06T15:02:18.663496Z mysqld_safe Logging to '/var/log/mysqld.log'.
2017-01-06T15:02:18.666764Z mysqld_safe Logging to '/var/log/mysqld.log'.
2017-01-06T15:02:18.693025Z mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
^C
[root@coderknock ~]# mysql -u root mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
 
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.17 MySQL Community Server (GPL)
 
Copyright (c) 2000, 2016, 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>update mysql.user set authentication_string=password('你的密码.') where User='root';
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 1
mysql> flush privileges;
mysql> update mysql.user set Host='%' where User='root'
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 1
mysql> flush privileges;

注意SQL在Linux下要注意大小写,执行之后Query OK, 1 row affected, 1 warning (0.00 sec),row 之前是1才代表执行成功了。update mysql.user set Host='%' where User='root' 这句是为了别的 IP 的机器也可以登录我们的MySQL,可以按需执行

重置密码

无论是获取到了默认密码还是强行修改了密码。新版 MySQL 在第一次通过密码登录后会无法执行SQL:

1
2
mysql> select host from mysql.user where User='root';
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

这是因为 MySQL 为了安全会要求修改初始密码。

mysql> ALTER USER 'root'@'%' IDENTIFIED BY '你的密码';

如果遇到ERROR 1819 (HY000): Your password does not satisfy the current policy requirements说明你的密码太简单,需要设置复杂点的密码,有大小写字母、有数字、有标点基本上就可以通过。 
注意,如果你没有修改过 root 用户的Host或者修改为非 % 的字符,需要对上面的语句进行对应的修改,例如: ALTER USER ‘root'@'localhost' IDENTIFIED BY ‘你的密码'

如果遇到ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement 则需要退出安全模式,正常启动MySQL后登陆再进行以上操作:

1
2
3
4
5
6
7
8
9
10
11
12
mysql> quit
[root@coderknock ~]# ps -ef|grep mysql
root 14208 12686 0 23:02 pts/0 00:00:00 /bin/sh /usr/bin/mysqld_safe --user=mysql --skip-grant-tables --skip-networking
mysql 14381 14208 0 23:02 pts/0 00:00:00 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --user=mysql --skip-grant-tables --skip-networking --log-error=/var/log/mysqld.log --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/lib/mysql/mysql.sock
root 15148 12686 0 23:23 pts/0 00:00:00 grep mysql
[root@coderknock ~]# kill -9 114208
-bash: kill: (114208) - No such process
[root@coderknock ~]# kill -9 14208
[1]+ Killed   mysqld_safe --user=mysql --skip-grant-tables --skip-networking
[root@coderknock ~]# kill -9 1438
[root@coderknock ~]# service mysqld start
[root@coderknock ~]# mysql -u root mysql

精彩专题分享:mysql不同版本安装教程 mysql5.7各版本安装教程

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。

Centos MySQL 5.7安装、升级教程的更多相关文章

  1. Navicat 12.x for MySQL最新版安装破解教程(附安装包和注册机,全网独家可用

    title: "Navicat 12.x for MySQL最新版安装破解教程(附安装包和注册机,全网独家可用" categories: soft tags: soft autho ...

  2. MySQL二进制快速安装升级(待验证)

    适合小版本的升级. 即 关闭当前的MySQL,替换当前的二进制文件或包,在现有的数据目录上重启MySQL,并运行mysql_upgrade. 特点:不改变数据文件,升级速度快:但,不可以跨操作系统,不 ...

  3. Win10系统下MySQL压缩版安装配置教程

    MySQL分为安装版和压缩.为了以后MySQL出问题想重装时的各种不必要的麻烦,我个人推荐压缩版MySQL.下面进入教程: 进入官网下载MySQL压缩包,并解压如下 配置环境变量---将bin文件的目 ...

  4. linux下mysql 最新版安装图解教程

    1.查看当前安装的linux版本 命令:lsb_release -a 如下图所示 通过上图中的数据可以看出安装的版本为RedHat5.4,所以我们需要下载RedHat5.4对应的mysql安装包 2. ...

  5. MySQL 下载与安装使用教程

    MySQL 官网地址:https://www.mysql.com/ 等待下载完成 双击运行 如果有需要 我们可以新增一个用户出来 点击 Add User,不需要的话 直接 点击 next 默认的MyS ...

  6. CentOS 7使用yum安装SNMP教程

    一.安装SMNP yum install -y net-snmp net-snmp-utils 可以理解为net-snmp是服务端,net-snmp-utils是客户端工具集:如果机器上只需要搭建服务 ...

  7. CentOS(Linux)安装KETTLE教程 并配置执行定时任务

    1,首先是安装jdk,并设置环境变量 采用yum安装可不设置环境变量 2,下载kettle https://sourceforge.net/projects/pentaho/files/Data%20 ...

  8. Redis在CentOS for LInux上安装详细教程

    1.首先上传安装包,这里我以 redis-5.0.8.tar.gz 为例子. Linux下载redis地址:wget http://download.redis.io/releases/redis-5 ...

  9. Centos(Linux)安装openoffice教程

    一.从官网下载openoffice软件 下载地址:http://www.openoffice.org/zh-cn/download/ 选择(RPM)类型进行下载,选择对应的版本,这里默认选择是最新的版 ...

随机推荐

  1. 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 GSM Base Station Identification (点在多边形内模板)

    In the Personal Communication Service systems such as GSM (Global System for Mobile Communications), ...

  2. VS2010MFC编程入门

    一.MFC编程入门教程之目录 第1部分:MFC编程入门教程之目录 1.MFC编程入门之前言  鸡啄米的C++编程入门系列给大家讲了C++的编程入门知识,大家对C++语言在语法和设计思想上应该有了一定的 ...

  3. cannot access Input/output error

    ls: cannot access  Input/output errorls: cannot open directory .: Input/output error 硬盘故障,只读或只写,你可以d ...

  4. LOJ 2541 「PKUWC2018」猎人杀——思路+概率+容斥+分治

    题目:https://loj.ac/problem/2541 看了题解才会……有三点很巧妙. 1.分母如果变动,就很不好.所以考虑把操作改成 “已经选过的人仍然按 \( w_i \) 的概率被选,但是 ...

  5. Toposort(拓扑排序)dfs递归模板

    最近刷了几题拓扑排序的题,记录一下拓扑排序 在有向图中,并且按照一定的规则(题目所给的规则)排序.如果图中出现了有向环的话就无法排序了. int gap[maxn][maxn];//记录下有向边 in ...

  6. python input() 与raw_input()

    使用input和raw_input都可以读取控制台的输入,但是input和raw_input在处理数字时是有区别的1:纯数字输入 当输入为纯数字时 input返回的是数值类型,如int,float   ...

  7. Oracle 简单统计示例

    有数据如下: eg1:现在需要统计所有男性人员数量,所有女性人员数量,sclassno=10000的男性人员的总年龄,年龄大于20的女性人员数量 ----sign( number )/*If numb ...

  8. Protocol协议分发器

    1. 用途: 能够制定多个对象实现<Protocol>, 同一个代理方法,可以在多个对象中同时实现 2.原理: 利用消息转发机制,将方法分发到多个对象中 使用方式: self.tableV ...

  9. iOS OpenGL ES简单绘制三角形

    OpenGL 是用于2D/3D图形编程的一套基于C语言的统一接口. windows,Linux,Unix上均可兼容. OpenGL ES 是在OpenGL嵌入式设备上的版本, android/iOS ...

  10. CF1241 D Sequence Sorting(离散化+DP)

    题意: 给定数组a[n],用两种操作: 1.将数组中所有值为x的数移至开头 2.将数组中所有值为x的数移至末尾 问,经过最少多少次操作,能将数组a[n]变为非递减的有序数列? (1<=n< ...