程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> MYSQL數據庫 >> MySQL綜合教程 >> mysql-5.5forlinux源碼安裝

mysql-5.5forlinux源碼安裝

編輯: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>

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved