最近需要使用MySQL Fabric,这货是MySQL5.6.10之后才出现的utility。手头机器装的是MySQL5.1,所以需要先把旧版MySQL升级成5.6版本。之前没有玩过MySQL,所以这次稍微费了点事。在此,把过程记录下来,希望能给有需求的人提供一点帮助。下面我们就正式开始。
1. 删除老版本MySQL
其实删除老版MySQL是一件很简单的事,但是开始时候由于担心各个包的依赖会导致各种问题,亦步亦趋来得很慢。其实只需要做到这么几步就可以了:1.1 查看已安装的mysql版本并删除
查看已安装的mysql版本:rpm -qa | grep -i mysql
只要将client/server两个rpm包卸载就可以,过程中可能会提示某个包的依赖,加上--nodeps即可。
1.2 删除数据文件
删除/etc/my.cnf以及安装目录/usr/local/mysql/(该目录位置是安装时指定的)下的数据文件。 rm -r /etc/my.cnf rm -rf /usr/local/mysql1.3 查看当前是否有mysql在运行
这一步经常会被忽视掉,所以需要稍微注意下。若有则kill掉。使用命令:ps -fe | grep mysql查看。经过上面的三个步骤,基本就可以把旧版mysql卸载掉了。其他遗留部分在后续安装新版mysql时,会提示有不兼容的情况,到时候再逐个删除即可。
2. 源码安装MySQL5.6
前提一:既然是源码安装,肯定要先下载一份MySQL源码了。这个大家根据自己的需求下载,在此就不赘述了。前提二:安装cmake。MySQL的编译是使用的cmake,所以需要提前安装好。这个过程也很简单,就不说了。上面的准备工作都OK之后,就开始正式安装的过程了。2.1 编译
与linux上其他的工程一样,MySQL的编译也就是make/make install。2.1.1 cmake
在代码路径下执行:cmake ./ -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ -DMYSQL_DATADIR=/usr/local/mysql/data \ -DSYSCONFDIR=/etc \ -DWITH_MYISAM_STORAGE_ENGINE=1 \ -DWITH_INNOBASE_STO…上面的编译参数,有几个在后续的安装过程中需要使用,在此说明一下。其他的可以不用管,直接复制即可。 DCMAKE_INSTALL_PREFIX:MySQL的安装路径,安装完成后就是MySQL的工作路径。
DMYSQL_DATADIR:MySQL的数据文件位置。
DSYSCONFDIR:MySQL的配置文件位置。
2.1.2 make && make install
这个用过linux的都知道吧。。到此,编译的过程就完成了。2.2 安装
# cd /usr/local/mysql # chown -R mysql:mysql . # chown -R mysql:mysql ./data # scripts/mysql_install_db --defaults-file=/etc/my.cnf # cp support-files/my-default.cnf /etc/my.cnf上面这些都是MySQL的配置过程,其中的路径必须和上面cmake的参数保持一致。其中mysql的配置文件/etc/my.cnf需要注意,下面是我的配置文件,基本保持这样就可以了。
[mysql] socket = /tmp/mysqld.sock [mysqld] user = mysql datadir = /usr/local/mysql/data port=3306
2.3 启动MySQL
有三种方法可以启动MySQL,分别如下:方法一: # bin/mysqld_safe --defaults-file=/etc/my.cnf 方法二: # bin/mysqld 方法三: cp support-files/msql.server /etc/init.d/mysql service mysql start相信大家对第三种方法更熟悉,使用start|restart|stop来启动/重启/停止一个服务的操作,在linux中使用的十分广泛。我也习惯使用这种方法,但是在使用过程中发现一个情况。使用service mysql start时,如果服务启动失败,基本不会有什么错误log输出,所以想判断是什么原因导致的启动失败就比较困难。这时候推荐使用方法二来启动,它会将错误原因输出,对于勘误难说容易的多。 查看启动是否成功:ps -ef | grep mysql
2.4 修改root密码
# ./bin/mysqladmin -u root password两遍输入密码即可。修改完密码之后,需要重启一下mysql。到此,MySQL从老版本升级的过程就完成了。

InnoDBBufferPool reduces disk I/O by caching data and indexing pages, improving database performance. Its working principle includes: 1. Data reading: Read data from BufferPool; 2. Data writing: After modifying the data, write to BufferPool and refresh it to disk regularly; 3. Cache management: Use the LRU algorithm to manage cache pages; 4. Reading mechanism: Load adjacent data pages in advance. By sizing the BufferPool and using multiple instances, database performance can be optimized.

Compared with other programming languages, MySQL is mainly used to store and manage data, while other languages such as Python, Java, and C are used for logical processing and application development. MySQL is known for its high performance, scalability and cross-platform support, suitable for data management needs, while other languages have advantages in their respective fields such as data analytics, enterprise applications, and system programming.

MySQL is worth learning because it is a powerful open source database management system suitable for data storage, management and analysis. 1) MySQL is a relational database that uses SQL to operate data and is suitable for structured data management. 2) The SQL language is the key to interacting with MySQL and supports CRUD operations. 3) The working principle of MySQL includes client/server architecture, storage engine and query optimizer. 4) Basic usage includes creating databases and tables, and advanced usage involves joining tables using JOIN. 5) Common errors include syntax errors and permission issues, and debugging skills include checking syntax and using EXPLAIN commands. 6) Performance optimization involves the use of indexes, optimization of SQL statements and regular maintenance of databases.

MySQL is suitable for beginners to learn database skills. 1. Install MySQL server and client tools. 2. Understand basic SQL queries, such as SELECT. 3. Master data operations: create tables, insert, update, and delete data. 4. Learn advanced skills: subquery and window functions. 5. Debugging and optimization: Check syntax, use indexes, avoid SELECT*, and use LIMIT.

MySQL efficiently manages structured data through table structure and SQL query, and implements inter-table relationships through foreign keys. 1. Define the data format and type when creating a table. 2. Use foreign keys to establish relationships between tables. 3. Improve performance through indexing and query optimization. 4. Regularly backup and monitor databases to ensure data security and performance optimization.

MySQL is an open source relational database management system that is widely used in Web development. Its key features include: 1. Supports multiple storage engines, such as InnoDB and MyISAM, suitable for different scenarios; 2. Provides master-slave replication functions to facilitate load balancing and data backup; 3. Improve query efficiency through query optimization and index use.

SQL is used to interact with MySQL database to realize data addition, deletion, modification, inspection and database design. 1) SQL performs data operations through SELECT, INSERT, UPDATE, DELETE statements; 2) Use CREATE, ALTER, DROP statements for database design and management; 3) Complex queries and data analysis are implemented through SQL to improve business decision-making efficiency.

The basic operations of MySQL include creating databases, tables, and using SQL to perform CRUD operations on data. 1. Create a database: CREATEDATABASEmy_first_db; 2. Create a table: CREATETABLEbooks(idINTAUTO_INCREMENTPRIMARYKEY, titleVARCHAR(100)NOTNULL, authorVARCHAR(100)NOTNULL, published_yearINT); 3. Insert data: INSERTINTObooks(title, author, published_year)VA


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

SublimeText3 Linux new version
SublimeText3 Linux latest version

Dreamweaver Mac version
Visual web development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SublimeText3 Mac version
God-level code editing software (SublimeText3)