CentOS6CentOS
一、卸载旧版本MySql
1、rpm卸载:
1> 检查安装包:
rpm -qa | grep mysql
2> 普通删除:
rpm -e mysql-5.6.16.rpm
3> 强力删除。如果使用上面命令删除时,提示有依赖的其他文件,则使用该命令可以对其进行强力删除。
rpm -e --nodeps mysql-5.6.16.rpm
2、tar卸载:
1> 删除临时文件:
make clean
2> 卸载
make uninstall
3> 删除解压文件
rm -rf 文件夹
3、yum卸载:
1> 卸载一个软件:
yum remove package_name
2> 卸载多个:
yum remove package_name1 package_name2 package_name3
二、安装MySql
1、安装编译器gcc-c++:
yum -y install make gcc-c++ cmake bison-devel ncurses-devel
2、下载并解压:
1> 下载tar安装包:
wget http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.16.tar.gz
2> 解压安装包:
tar -xzvf mysql-5.6.16.tar.gz
3> 给解压文件重命名:
mv mysql-5.6.16 mysql
3、编译安装:
1、进入安装目录:
cd mysql
2、配置参数:
cmake /
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql /
-DMYSQL_DATADIR=/home/mysql/data /
-DSYSCONFDIR=/etc
-DWITH_MYISAM_STORAGE_ENGINE=1 /
-DWITH_INNOBASE_STORAGE_ENGINE=1 /
-DWITH_MEMORY_STORAGE_ENGINE=1 /
-DWITH_READLINE=1 /
-DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock /
-DMYSQL_TCP_PORT=3306 /
-DENABLED_LOCAL_INFILE=1 /
-DWITH_PARTITION_STORAGE_ENGINE=1 /
-DEXTRA_CHARSETS=all /
-DDEFAULT_CHARSET=utf8 /
-DDEFAULT_COLLATION=utf8_general_ci
3> 编译安装:
make && make install
编译的参数可以参考http://dev.mysql.com/doc/refman/5.5/en/source-configuration-options.html。
整个过程需要30分钟左右……漫长的等待
三、配置MySql:
1、设置权限:
1> 使用下面的命令查看是否有mysql用户及用户组:
cat /etc/passwd 查看用户列表
cat /etc/group 查看用户组列表
2> 如果没有就创建:
groupadd mysql
useradd -g mysql mysql
3> 修改/usr/local/mysql权限:
chown -R mysql:mysql /usr/local/mysql
2、初始化配置:
1> 进入安装路径
cd /usr/local/mysql
2、进入安装路径,执行初始化配置脚本,创建系统自带的数据库和表:
scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/home/mysql/data --user=mysql
注:在启动MySQL服务时,会按照一定次序搜索my.cnf,先在/etc目录下找,找不到则会搜索"$basedir/my.cnf",在本例中就是 /usr/local/mysql/my.cnf,这是新版MySQL的配置文件的默认位置!注意:在CentOS 6.4版操作系统的最小安装完成后,在/etc目录下会存在一个my.cnf,需要将此文件更名为其他的名字,如:/etc/my.cnf.bak,否则,该文件会干扰源码安装的MySQL的正确配置,造成无法启动。
3、启动MySQL:
1> 添加服务,拷贝服务脚本到init.d目录,并设置开机启动并生效(可以不设置)
cp support-files/mysql.server /etc/init.d/mysql
chkconfig mysql on
2> 启动MySql:
service mysql start --启动MySQL
4、配置用户
MySQL启动成功后,root默认没有密码,我们需要设置root密码。
设置之前,我们需要先设置PATH,要不不能直接调用mysql
1> 修改/etc/profile文件,在文件末尾添加
PATH=/usr/local/mysql/bin:$PATH
export PATH
2> 使环境变量配置文件立即生效:
source /etc/profile
3> 在终端内直接输入mysql进入mysql的环境,执行下面的命令修改root密码:
mysql -uroot
mysql> SET PASSWORD = PASSWORD('123456');
4> 若要设置root用户可以远程访问,执行
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'172.16.%' IDENTIFIED BY 'password' WITH GRANT OPTION;
红色的password为远程访问时,root用户的密码,可以和本地不同。
5、配置防火墙:(如果不使用防火墙,这一步可以不用)
1> 防火墙的3306端口默认没有开启,若要远程访问,需要开启这个端口
打开/etc/sysconfig/iptables
在“-A INPUT

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

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

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

Dreamweaver Mac version
Visual web development tools

WebStorm Mac version
Useful JavaScript development tools

Zend Studio 13.0.1
Powerful PHP integrated development environment