1. Media Preparation
Note: Due to the Mysql5.5 source code compiled using the CMake method, so download the CMake installation package and MySQL5.5 installation package in advance
As follows:
http://mysql.mirror.kangaroot.net/Downloads/MySQL-5.5/
Http://www.cmake.org/files/v2.8/cmake-2.8.10.2.tar.gz
Upload to the specified server after the download is complete.
2. Installing dependent Packages
There are many dependencies that need to be installed, so it is recommended to install using Yum source installation, in fact, many packages are optional. (bold fonts are required to be installed)
Yum-y Install gcc* gcc-c++* autoconf* automake* zlib* libxml* ncurses-devel* libgcrypt* libtool*
3. Create a MySQL user
[Email protected] ~]# groupadd MySQL #添加mysql用户组
[Email protected] ~]# useradd mysql-g mysql-s/sbin/nologin #
添加mysql用户
4. Create the installation directory and empower
Installation path:/opt/mysql
database path:/opt/mysql /data
Source Package storage location:/project
Mkdir-p/opt/mysql/data
Chown-r Mysql.mysql/opt/mysql
5. Installing the CMake Compilation tool
Tar zxvf cmake-2.8.4.tar.gz
CD cmake-2.8.4
./configure
Make
Make install
Note: After the installation is complete, it is best to add cmake to/etc/profilea
Path=/project/cmake-2.8.10.2/bin: $PATH
Export PATH
6. Unzip the source package and enter the directory
Tar xzvf mysql-5.5.33-linux2.6-x86_64.tar.gz
CD mysql-5.5.33-linux2.6-x86_64
7. Compile the installation, configure the compilation parameters
Compilation tips: It is best to create a project in the source directory, in the project to compile, so that the source code and compile can be divided into clear.
[email protected] ~]# cmake. -dcmake_install_prefix=/opt/mysql \
-dmysql_unix_addr=/opt/mysql/mysql.sock \
-ddefault_charset=utf8 \
-ddefault_collation=utf8_general_ci \
-DWITH_EXTRA_CHARSETS:STRING=UTF8,GBK \
-dwith_innobase_storage_engine=1 \
-dwith_readline=1 \
-denabled_local_infile=1 \
-dmysql_datadir=/opt/mysql/data/\
-dmysql_tcp_port=3306
[[email protected] ~]# make && make install
The above seven steps are done, MySQL has been installed, now to introduce the database initialization files and configuration start.
8. Set the environment variables, add the MySQL command to the path path, I demonstrated to add to the ~/.bash_profile, you can also add to/etc/profile
Path=/opt/mysql/bin: $PATH: $HOME/bin
SOURCE ~/.bash_profile
9. Add the MySQL configuration file to the/etc directory
[email protected] ~]# CP support-files/my-small.cnf/etc/my.cnf #mysql配置文件
[Email protected] ~]# chmod 755 scripts/mysql_install_db #赋予mysql_install_db执行权限
[Email protected] ~]# scripts/mysql_install_db--user=mysql--basedir=/opt/mysql--datadir=/opt/mysql/ data/
If you see two OK words, the initialization succeeds
Add MySQL to the system service
[Email protected] ~]# CP support-files/mysql.server/etc/init.d/mysqld
[Email protected] ~]# chmod 755/etc/init.d/mysqld
10. Start the MySQL service
Service mysqld Start
11. Add MySQL account password
mysqladmin-u root password ' yourpassword '
MySQL has two account types, localhost and%, which are native to MySQL, which can be used for remote connection of MySQL to other machines.
Finally, handle account login issues, so that the root account password can be used for local and remote connections
[[email protected] ~]#/usr/local/mysql/bin/mysql-u root-p #敲入该命令后, the screen will prompt for a password, enter the previous step Set of YourPassword
Delete the record with the root password blank
mysql> use MySQL;
mysql> Delete from user where password= ';
mysql> flush Privileges;
Configure MySQL to allow root telnet #登录
Mysql> Grant all privileges on * * to [e-mail protected] '% ' identified by ' root ';
mysql> flush Privileges;
End
CentOS under source installation MySQL5.5 (Single instance)