Install mysql-5.5forlinux source code Mysql-5.5 for linux source code installation 1. use Yum to install dependency packages
# Yum install-y gcc-c ++ gcc-g77 autoconf automake bison zlib * fiex */
Libxml * ncurses-devel libmcrypt * libtool-ltdl-devel *
2. install cmake
# Yum install-y cmake
3. decompress and compile and install the MySQL source package
# Tar xzvf mysql-5.5.27.tar.gz
# Music mysql-5.5.27 mysql
# Cd mysql
# Configure compilation (refer to: 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
Note:
During re-compilation, you need to clear the old object file and cache information.
# Make clean
# Rm-f CMakeCache.txt
4. add mysql users and user groups and modify all directory permissions
[Root @ ttt mysql] # groupadd mysql
[Root @ ttt mysql] # useradd-r-g mysql
[Root @ ttt mysql] # chown-R mysql/usr/local/mysql
[Root @ ttt mysql] # chgrp-R mysql/usr/local/mysql
5. install the basic database and copy the sample configuration file.
# 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 // global declaration PATH of the mysql command
[Root @ ttt ~] # Echo "PATH = $ PATH:/usr/local/mysql/bin">/etc/profile // write the boot startup file
6. Register mysql system service and start mysql
[Root @ ttt mysql] # chmod 755 support-files/mysql. server
[Root @ ttt mysql] # ls-l support-files/mysql. server
-Rwxr-xr-x 1 mysql 10650 June 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: disable 1: disable 2: Enable 3: Enable 4: enable 5: Enable 6: disable
[Root @ ttt mysql] # service mysql start
Starting MySQL... [OK]
[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 00:00:00 pts/0/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 00:00:00 pts/0 grep mysql
7. after the installation is complete, start the mysql database and enter the test.
[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,201 1, 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. modify the mysql database root user password and perform logon verification.
[Root @ ttt ~] # Mysqladmin-u root password 'mysqlpass' -- set a password for the "root" user
[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,201 1, 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>