Home Database Mysql Tutorial CentOS下MySQL 5.1升级到5.7

CentOS下MySQL 5.1升级到5.7

Jun 07, 2016 pm 04:42 PM

今天在CentOS上将MySQL版本由5.1升级到5.7的时候出现了各种问题,不过经过一步步的调查解决了问题,下面就记录一下过程,其中经历

前言:今天在CentOS上将MySQL版本由5.1升级到5.7的时候出现了各种问题,不过经过一步步的调查解决了问题,下面就记录一下过程,其中经历了很多次的卸载和删除,在这次记录的过程中,我就按照最后成功的一次顺序来记录,对于其中可能出现的一些错误会做特殊的说明。

1.下载Linux的5.7版本,主要需要两个文件

MySQL-server-5.7.4_m14-1.el6.x86_64.rpm
MySQL-client-5.7.4_m14-1.el6.x86_64.rpm

2.备份数据库文件

mysqldump -uxxx -pxx databasename > databasename.sql

3.停止mysql服务

service mysql stop

4.刚开始使用的yum安装的,使用以下语句进行卸载[plain] view plaincopyprint?yum remove mysql*

yum remove mysql*

5.然后删除mysql旧版本已经存在的文件或者数据,不然mysql在重新安装后会出现各种纠结的问题。

find / -name mysql
ps -ef | grep -i mysql

rm -rf mysql****
kill -9 mysqlid

注意/usr/bin、/usr/share/、/var/lib下有很多mysql开头的文件,都删除掉,还有删除/etc目录下的my.cnf文件

6.如果你是rpm安装的,可以通过以下命令进行删除

rpm -qa | grep -i name
rpm -e mysqlxxxxx

7.卸载删除干净后,再使用以下命令对下载的server和client进行安装

rpm -ivh mysqlxxx

8.我将my.cnf中的一部分进行了优化,按照我们的项目需要做了调整,拿出来做为参照

 [mysqld]
  2 datadir=/var/lib/mysql
  3 socket=/var/lib/mysql/mysql.sock
  4 #user=mysql
  5
  6 # Disabling symbolic-links is recommended to prevent assorted security risks
  7 symbolic-links=0
  8 #设置2进制日志文件目录
  9 log-bin=mysql-bin

#10行不设置的话,会报一个莫名的错误

 10 server-id=1
 11 #指定索引的缓冲区大小,4G内存下设置256或者384合适
 12 key_buffer_size = 256M
 13 #每打开一个表,都会读入数据到table_open_cache中,
 14 table_open_cache = 256
 15 #用于ORDER BY时的缓冲大小,是针对的每个连接,所以不能太大
 16 sort_buffer_size = 256K
 17 #对表进行顺序扫描的请求
 18 read_buffer_size = 256K
 19 #任意顺序读取行时
 20 read_rnd_buffer_size = 512K
 21 #查询到内容向网络传输时
 22 net_buffer_length = 8K
 23 #保存在缓存中的线程数量,
 24 thread_cache_size = 20
 25 ##由于项目中一些表的增删改相对比较频繁,但是查询也占据了很大的一部分,还需要项目运行后观察一段时间
 26 query_cache_size= 8M
 27 # 和cpu的核心数有2倍的关系,我使用的是云服务器,设置这个参数后就启动不起来了
 28 #thread_concurrency = 12
 29
 30 #提交事务后数据写入磁盘的时间点,设置为2可以对没有强烈的安全要求机制下,对速度提高很大
 31 innodb_flush_log_at_trx_commit = 2
 32
 33 #如果使用mysql命令登录客户端的时候报权限错误或者密码的错误,可以通过开启标记跳过验证,直接通过mysql进行连接,然后再修改用户名权限
 34 #skip-grant-tables
 35
 36 [mysqld_safe]
 37 log-error=/var/log/mysqld.log
 38 pid-file=/var/run/mysqld/mysqld.pid

9.在安装的过程中出现了mysql error 1524错误,没有找出来是什么原因,可以通过设置skip-grant-tables跳过错误,,然后又出现了error 1045(28000)错误,我把8步骤中的user=mysql注释掉了,这个过程中还出现了其他一些错误,暂时记不起来了,然后通过以上的设置后,再重启mysql服务后,就可以通过mysql -uxxx -pxx进行登录了,然后又出现了一个问题error 1820,然后查资料说通过以下操作进行实现

mysql> create database ttt;
ERROR 1820 (HY000): You must SET PASSWORD before executing this statement
mysql> set password = password("root");
Query OK, 0 rows affected (0.00 sec)

10.OK,终于正常了,然后通过source命令把sql文件导入。

--------------------------------------分割线 --------------------------------------

Ubuntu 14.04下安装MySQL

《MySQL权威指南(原书第2版)》清晰中文扫描版 PDF

Ubuntu 14.04 LTS 安装 LNMP Nginx\PHP5 (PHP-FPM)\MySQL

Ubuntu 14.04下搭建MySQL主从服务器

Ubuntu 12.04 LTS 构建高可用分布式 MySQL 集群

Ubuntu 12.04下源代码安装MySQL5.6以及Python-MySQLdb

MySQL-5.5.38通用二进制安装

--------------------------------------分割线 --------------------------------------

本文永久更新链接地址:

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Explain InnoDB Full-Text Search capabilities. Explain InnoDB Full-Text Search capabilities. Apr 02, 2025 pm 06:09 PM

InnoDB's full-text search capabilities are very powerful, which can significantly improve database query efficiency and ability to process large amounts of text data. 1) InnoDB implements full-text search through inverted indexing, supporting basic and advanced search queries. 2) Use MATCH and AGAINST keywords to search, support Boolean mode and phrase search. 3) Optimization methods include using word segmentation technology, periodic rebuilding of indexes and adjusting cache size to improve performance and accuracy.

How do you alter a table in MySQL using the ALTER TABLE statement? How do you alter a table in MySQL using the ALTER TABLE statement? Mar 19, 2025 pm 03:51 PM

The article discusses using MySQL's ALTER TABLE statement to modify tables, including adding/dropping columns, renaming tables/columns, and changing column data types.

When might a full table scan be faster than using an index in MySQL? When might a full table scan be faster than using an index in MySQL? Apr 09, 2025 am 12:05 AM

Full table scanning may be faster in MySQL than using indexes. Specific cases include: 1) the data volume is small; 2) when the query returns a large amount of data; 3) when the index column is not highly selective; 4) when the complex query. By analyzing query plans, optimizing indexes, avoiding over-index and regularly maintaining tables, you can make the best choices in practical applications.

Can I install mysql on Windows 7 Can I install mysql on Windows 7 Apr 08, 2025 pm 03:21 PM

Yes, MySQL can be installed on Windows 7, and although Microsoft has stopped supporting Windows 7, MySQL is still compatible with it. However, the following points should be noted during the installation process: Download the MySQL installer for Windows. Select the appropriate version of MySQL (community or enterprise). Select the appropriate installation directory and character set during the installation process. Set the root user password and keep it properly. Connect to the database for testing. Note the compatibility and security issues on Windows 7, and it is recommended to upgrade to a supported operating system.

Difference between clustered index and non-clustered index (secondary index) in InnoDB. Difference between clustered index and non-clustered index (secondary index) in InnoDB. Apr 02, 2025 pm 06:25 PM

The difference between clustered index and non-clustered index is: 1. Clustered index stores data rows in the index structure, which is suitable for querying by primary key and range. 2. The non-clustered index stores index key values ​​and pointers to data rows, and is suitable for non-primary key column queries.

What are some popular MySQL GUI tools (e.g., MySQL Workbench, phpMyAdmin)? What are some popular MySQL GUI tools (e.g., MySQL Workbench, phpMyAdmin)? Mar 21, 2025 pm 06:28 PM

Article discusses popular MySQL GUI tools like MySQL Workbench and phpMyAdmin, comparing their features and suitability for beginners and advanced users.[159 characters]

How do you handle large datasets in MySQL? How do you handle large datasets in MySQL? Mar 21, 2025 pm 12:15 PM

Article discusses strategies for handling large datasets in MySQL, including partitioning, sharding, indexing, and query optimization.

How do you drop a table in MySQL using the DROP TABLE statement? How do you drop a table in MySQL using the DROP TABLE statement? Mar 19, 2025 pm 03:52 PM

The article discusses dropping tables in MySQL using the DROP TABLE statement, emphasizing precautions and risks. It highlights that the action is irreversible without backups, detailing recovery methods and potential production environment hazards.

See all articles