search
HomeDatabaseMysql Tutorialmysql-5.5 for linux源码安装_MySQL

mysql-5.5 for linux源码安装

1.使用Yum安装依赖软件包

# yum install -y gcc gcc-c++ gcc-g77 autoconf automake bison zlib* fiex* /

libxml* ncurses-devel libmcrypt* libtool-ltdl-devel*

2.安装cmake

# yum install -y cmake

3.解压缩并编译安装MySQL源码包

# tar xzvf mysql-5.5.27.tar.gz

# mv mysql-5.5.27 mysql

# cd mysql

#配置编译(参考:http://dev.mysql.com/doc/refman/5.5/en/source-configuration-options.html)

# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql /

-DSYSCONFDIR=/usrl/local/mysql/etc /

-DMYSQL_DATADIR=/usr/local/mysql/data /

-DMYSQL_TCP_PORT=3306 /

-DMYSQL_UNIX_ADDR=/tmp/mysql.sock /

-DMYSQL_USER=mysql /

-DDEFAULT_CHARSET=utf8 /

-DDEFAULT_COLLATION=utf8_general_ci /

-DWITH_EXTRA_CHARSETS=all /

-DWITH_READLINE=1 /

-DWITH_SSL=system /

-DWITH_EMBEDDED_SERVER=1 /

-DENABLED_LOCAL_INFILE=1 /

-DWITH_MYISAM_STORAGE_ENGINE=1 /

-DWITH_MEMORY_STORAGE_ENGINE=1 /

-DWITH_INNOBASE_STORAGE_ENGINE=1

# make

# make install

注意事项:

重新编译时,需要清除旧的对象文件和缓存信息。

# make clean

# rm -f CMakeCache.txt

4.添加mysql用户及用户组并修改目录所有权限

[root@ttt mysql]# groupadd mysql

[root@ttt mysql]# useradd -r -g mysql mysql

[root@ttt mysql]# chown -R mysql /usr/local/mysql

[root@ttt mysql]# chgrp -R mysql /usr/local/mysql

5.安装基础数据库并复制示例配置文件

# cd /usr/local/mysql

# chmod +x scripts/*

[root@ttt mysql]#  ./scripts/mysql_install_db --basedir=/usr/local/mysql /

--datadir=/usr/local/mysql/data --user=mysql

# cp /usr/local/mysql/support-files/my-medium.cnf /etc/my.cnf

[root@ttt ~]# export PATH=$PATH:/usr/local/mysql/bin    //全局宣告mysql命令的路径

[root@ttt ~]# echo "PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile   //写入开机启动文件

6.注册mysql系统服务并启动mysql

[root@ttt mysql]# chmod 755 support-files/mysql.server

[root@ttt mysql]# ls -l support-files/mysql.server

-rwxr-xr-x 1 mysql mysql 10650 6月  22 19:21 support-files/mysql.server

[root@ttt mysql]# cp support-files/mysql.server /etc/init.d/mysql

[root@ttt mysql]# chown root.root /etc/init.d/mysql

[root@ttt mysql]# chkconfig --add mysql

[root@ttt mysql]# chkconfig --level 35 mysql on

[root@ttt mysql]# chkconfig --list mysql

mysql           0:关闭  1:关闭  2:启用  3:启用  4:启用  5:启用  6:关闭

[root@ttt mysql]# service mysql start

Starting MySQL...                                          [确定]

[root@ttt mysql]# netstat -ltu |grep mysql

tcp        0      0 *:mysql               *:*                   LISTEN

[root@ttt mysql]# ps -ef | grep mysql

root     15492     1  0 21:00 pts/0    00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe

--datadir=/usr/local/mysql/data --pid-file=/usr/local/mysql/data/ttt.pid

mysql    15744 15492  0 21:00 pts/0    00:00:00 /usr/local/mysql/bin/mysqld --

basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-

dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/usr/local/mysql/data/ttt.err

--pid-file=/usr/local/mysql/data/ttt.pid --socket=/tmp/mysql.sock --port=3306

root     15896  1098  0 21:10 pts/0    00:00:00 grep mysql

7.安装完成,启动mysql数据库,进入测试

[root@ttt ~]# mysql -u root

Welcome to the MySQL monitor.  Commands end with ; or /g.

Your MySQL connection id is 3

Server version: 5.5.27-log Source distribution

Copyright (c) 2000, 2011, 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> show databases;

+--------------------+

| Database           |

+--------------------+

| information_schema |

| mysql              |

| performance_schema |

| test               |

+--------------------+

4 rows in set (0.00 sec)

mysql> use mysql

Database changed

mysql> show tables;

+---------------------------+

| Tables_in_mysql           |

+---------------------------+

| columns_priv              |

| db                        |

| event                     |

| func                      |

| general_log               |

| help_category             |

| help_keyword              |

| help_relation             |

| help_topic                |

| host                      |

| ndb_binlog_index          |

| plugin                    |

| proc                      |

| procs_priv                |

| proxies_priv              |

| servers                   |

| slow_log                  |

| tables_priv               |

| time_zone                 |

| time_zone_leap_second     |

| time_zone_name            |

| time_zone_transition      |

| time_zone_transition_type |

| user                      |

+---------------------------+

24 rows in set (0.00 sec)

mysql>

8.修改mysql数据库root用户密码并登录验证

[root@ttt ~]# mysqladmin -u root password 'mysqlpass'  --给“root”用户设置一个密码

[root@ttt ~]# mysql -u root -p

Enter password:

Welcome to the MySQL monitor.  Commands end with ; or /g.

Your MySQL connection id is 5

Server version: 5.5.27-log Source distribution

Copyright (c) 2000, 2011, 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> show databases;

+--------------------+

| Database           |

+--------------------+

| information_schema |

| mysql              |

| performance_schema |

| test               |

+--------------------+

4 rows in set (0.00 sec)

mysql>

Statement
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
Reduce the use of MySQL memory in DockerReduce the use of MySQL memory in DockerMar 04, 2025 pm 03:52 PM

This article explores optimizing MySQL memory usage in Docker. It discusses monitoring techniques (Docker stats, Performance Schema, external tools) and configuration strategies. These include Docker memory limits, swapping, and cgroups, alongside

How to solve the problem of mysql cannot open shared libraryHow to solve the problem of mysql cannot open shared libraryMar 04, 2025 pm 04:01 PM

This article addresses MySQL's "unable to open shared library" error. The issue stems from MySQL's inability to locate necessary shared libraries (.so/.dll files). Solutions involve verifying library installation via the system's package m

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.

Run MySQl in Linux (with/without podman container with phpmyadmin)Run MySQl in Linux (with/without podman container with phpmyadmin)Mar 04, 2025 pm 03:54 PM

This article compares installing MySQL on Linux directly versus using Podman containers, with/without phpMyAdmin. It details installation steps for each method, emphasizing Podman's advantages in isolation, portability, and reproducibility, but also

What is SQLite? Comprehensive overviewWhat is SQLite? Comprehensive overviewMar 04, 2025 pm 03:55 PM

This article provides a comprehensive overview of SQLite, a self-contained, serverless relational database. It details SQLite's advantages (simplicity, portability, ease of use) and disadvantages (concurrency limitations, scalability challenges). C

Running multiple MySQL versions on MacOS: A step-by-step guideRunning multiple MySQL versions on MacOS: A step-by-step guideMar 04, 2025 pm 03:49 PM

This guide demonstrates installing and managing multiple MySQL versions on macOS using Homebrew. It emphasizes using Homebrew to isolate installations, preventing conflicts. The article details installation, starting/stopping services, and best pra

How do I configure SSL/TLS encryption for MySQL connections?How do I configure SSL/TLS encryption for MySQL connections?Mar 18, 2025 pm 12:01 PM

Article discusses configuring SSL/TLS encryption for MySQL, including certificate generation and verification. Main issue is using self-signed certificates' security implications.[Character count: 159]

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]

See all articles

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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)