Linux CentOS6.6下编译安装MySQL 5.6.16 详细教程(亲测成功)
一、编译安装MySQL前的准备工作 安装编译源码所需的工具和库 [sql] view plain copy yuminstallgccgcc-cncurses-develperl 安装cmake 官方:http://www.cmake.org下载源码并编译安装 csdn下载地址:http://download.csdn.net/detail/chun8416/9514242 [sql]
一、编译安装MySQL前的准备工作
安装编译源码所需的工具和库
[sql] view plain copy


- yum install gcc gcc-c++ ncurses-devel perl
安装cmake
官方:http://www.cmake.org下载源码并编译安装
csdn下载地址:http://download.csdn.net/detail/chun8416/9514242
[sql] view plain copy

- wget http://www.cmake.org/files/v2.8/cmake-2.8.10.2.tar.gz
- tar -xzvf cmake-2.8.10.2.tar.gz
- cd cmake-2.8.10.2
- ./bootstrap ; make ; make install
- cd ~
二、设置MySQL用户和组
新增MySQL用户组
[sql] view plain copy

- groupadd mysql


- useradd -r -g mysql mysql
三、新建MySQL所需要的目录
新建mysql安装目录
[sql] view plain copy

- mkdir -p /usr/local/mysql


- mkdir -p /data/mysqldb
四、下载MySQL源码包并解压
从http://dev.mysql.com/downloads/mysql/直接下载源码,解压mysql-5.6.16.tar.gz(http://www.quseqi.com/这个网站就是用的5.6.16版本)
csdn下载地址:http://download.csdn.net/detail/chun8416/9514255
[sql] view plain copy

- wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.16.tar.gz
- tar -zxv -f mysql-5.6.16.tar.gz
- cd mysql-5.6.16
五、编译安装MySQL
从mysql5.5起,mysql源码安装开始使用cmake了,设置源码编译配置脚本。
设置编译参数
[sql] view plain copy


- cmake \
- -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
- -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \
- -DDEFAULT_CHARSET=utf8 \
- -DDEFAULT_COLLATION=utf8_general_ci \
- -DWITH_INNOBASE_STORAGE_ENGINE=1 \
- -DWITH_ARCHIVE_STORAGE_ENGINE=1 \
- -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
- -DMYSQL_DATADIR=/data/mysqldb \
- -DMYSQL_TCP_PORT=3306 \
- -DENABLE_DOWNLOADS=1
-DCMAKE_INSTALL_PREFIX=dir_name | 设置mysql安装目录 |
-DMYSQL_UNIX_ADDR=file_name | 设置监听套接字路径,这必须是一个绝对路径名。默认为/tmp/mysql.sock |
-DDEFAULT_CHARSET=charset_name | 设置服务器的字符集。 缺省情况下,MySQL使用latin1的(CP1252西欧)字符集。cmake/character_sets.cmake文件包含允许的字符集名称列表。 |
-DDEFAULT_COLLATION=collation_name | 设置服务器的排序规则。 |
-DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 |
存储引擎选项: MyISAM,MERGE,MEMORY,和CSV引擎是默认编译到服务器中,并不需要明确地安装。 静态编译一个存储引擎到服务器,使用-DWITH_engine_STORAGE_ENGINE= 1 可用的存储引擎值有:ARCHIVE, BLACKHOLE, EXAMPLE, FEDERATED, INNOBASE (InnoDB), PARTITION (partitioning support), 和PERFSCHEMA (Performance Schema) |
-DMYSQL_DATADIR=dir_name | 设置mysql数据库文件目录 |
-DMYSQL_TCP_PORT=port_num | 设置mysql服务器监听端口,默认为3306 |
-DENABLE_DOWNLOADS=bool | 是否要下载可选的文件。例如,启用此选项(设置为1),cmake将下载谷歌所使用的测试套件运行单元测试。 |
注:重新运行配置,需要删除CMakeCache.txt文件
[sql] view plain copy


- rm CMakeCache.txt
[sql] view plain copy


- make
[sql] view plain copy


- make install
六、修改mysql目录所有者和组
修改mysql安装目录
[sql] view plain copy


- cd /usr/local/mysql
- chown -R mysql:mysql .
[sql] view plain copy


- cd /data/mysqldb
- chown -R mysql:mysql .
七、初始化mysql数据库
[sql] view plain copy


- cd /usr/local/mysql
- scripts/mysql_install_db --user=mysql --datadir=/data/mysqldb
八、复制mysql服务启动配置文件
[sql] view plain copy


- cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf
九、复制mysql服务启动脚本及加入PATH路径
[sql] view plain copy


- cp support-files/mysql.server /etc/init.d/mysqld
- vim /etc/profile
- PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH
- export PATH
- source /etc/profile
十、启动mysql服务并加入开机自启动(可选这个步骤,以后可以自己启动的)
service mysqld start
chkconfig --level 35 mysqld on
十一、检查mysql服务是否启动
[sql] view plain copy


- netstat -tulnp | grep 3306
- mysql -u root -p
十二、修改MySQL用户root的密码
[sql] view plain copy


- mysqladmin -u root password '123456'
[sql] view plain copy


- /usr/local/mysql/bin/mysql_secure_installation
十三、可能会出现的错误
[sql] view plain copy


- 问题:
- Starting MySQL..The server quit without updating PID file ([FAILED]/mysql/Server03.mylinux.com.pid).
- 解决:
- 修改/etc/my.cnf 中datadir,指向正确的mysql数据库文件目录
[sql] view plain copy


- 问题:
- ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
- 解决:
- 新建一个链接或在mysql中加入-S参数,直接指出mysql.sock位置。
- ln -s /usr/local/mysql/data/mysql.sock /tmp/mysql.sock
- /usr/local/mysql/bin/mysql -u root -S /usr/local/mysql/data/mysql.sock
[sql] view plain copy


- MySQL问题解决:-bash:mysql:command not found
- 因为mysql命令的路径在/usr/local/mysql/bin下面,所以你直接使用mysql命令时,
- 系统在/usr/bin下面查此命令,所以找不到了
- 解决办法是:
- ln -s /usr/local/mysql/bin/mysql /usr/bin 做个链接即可

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 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

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

Hot Topics



You can open phpMyAdmin through the following steps: 1. Log in to the website control panel; 2. Find and click the phpMyAdmin icon; 3. Enter MySQL credentials; 4. Click "Login".

How to connect to MySQL using phpMyAdmin? The URL to access phpMyAdmin is usually http://localhost/phpmyadmin or http://[your server IP address]/phpmyadmin. Enter your MySQL username and password. Select the database you want to connect to. Click the "Connection" button to establish a connection.

The methods for viewing SQL database errors are: 1. View error messages directly; 2. Use SHOW ERRORS and SHOW WARNINGS commands; 3. Access the error log; 4. Use error codes to find the cause of the error; 5. Check the database connection and query syntax; 6. Use debugging tools.

The steps to start a Redis server include: Install Redis according to the operating system. Start the Redis service via redis-server (Linux/macOS) or redis-server.exe (Windows). Use the redis-cli ping (Linux/macOS) or redis-cli.exe ping (Windows) command to check the service status. Use a Redis client, such as redis-cli, Python, or Node.js, to access the server.

phpMyAdmin is not just a database management tool, it can give you a deep understanding of MySQL and improve programming skills. Core functions include CRUD and SQL query execution, and it is crucial to understand the principles of SQL statements. Advanced tips include exporting/importing data and permission management, requiring a deep security understanding. Potential issues include SQL injection, and the solution is parameterized queries and backups. Performance optimization involves SQL statement optimization and index usage. Best practices emphasize code specifications, security practices, and regular backups.

The key to PHPMyAdmin security defense strategy is: 1. Use the latest version of PHPMyAdmin and regularly update PHP and MySQL; 2. Strictly control access rights, use .htaccess or web server access control; 3. Enable strong password and two-factor authentication; 4. Back up the database regularly; 5. Carefully check the configuration files to avoid exposing sensitive information; 6. Use Web Application Firewall (WAF); 7. Carry out security audits. These measures can effectively reduce the security risks caused by PHPMyAdmin due to improper configuration, over-old version or environmental security risks, and ensure the security of the database.

Redis uses a single threaded architecture to provide high performance, simplicity, and consistency. It utilizes I/O multiplexing, event loops, non-blocking I/O, and shared memory to improve concurrency, but with limitations of concurrency limitations, single point of failure, and unsuitable for write-intensive workloads.

The five pillars of the Linux system are: 1. Kernel, 2. System library, 3. Shell, 4. File system, 5. System tools. The kernel manages hardware resources and provides basic services; the system library provides precompiled functions for applications; the shell is the interface for users to interact with the system; the file system organizes and stores data; and system tools are used for system management and maintenance.
