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>