源碼編譯安裝 MySQL 5.5.30


0、安裝cmake

[root@ www.linuxidc.com ~]# tar -zxvf cmake-2.8.11.2.tar.gz

[root@ www.linuxidc.com cmake-2.8.11.2]# ./configure

[root@ www.linuxidc.com cmake-2.8.11.2]# make

[root@ www.linuxidc.com cmake-2.8.11.2]# make install



1、添加mysql用戶和組

[root@ www.linuxidc.com ~]#groupadd mysql

[root@ www.linuxidc.com ~]#useradd -g mysql mysql


2、編譯MySQL程序


[root@ www.linuxidc.com tar_mysql]# tar -zxvf mysql-5.5.30.tar.gz

[root@ www.linuxidc.com ~]# cd mysql-5.5.30/

/usr/local/bin/cmake \

-DCMAKE_INSTALL_PREFIX=/usr/local/mysql5.5 \

-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \

-DDEFAULT_CHARSET=utf8 \

-DDEFAULT_COLLATION=utf8_general_ci \

-DWITH_EXTRA_CHARSETS:STRING=utf8,gbk,gb2312 \

-DWITH_MYISAM_STORAGE_ENGINE=1 \

-DWITH_INNOBASE_STORAGE_ENGINE=1  \

-DWITH_READLINE=1 \

-DENABLED_LOCAL_INFILE=1 \

-DMYSQL_DATADIR=/home/mysql/data \

-DWITH_DEBUG=0

[root@ www.linuxidc.com mysql-5.5.30]#  make && make install


3、拷貝數據庫的配置文件並做修改


[root@ www.linuxidc.com ~]# cp -ar /usr/local/mysql5.5/support-files/my-medium.cnf  /usr/local/mysql5.5/etc/lyq314.cnf


4、初始化數據庫


/usr/local/mysql5.5/scripts/mysql_install_db  --defaults-file=/usr/local/mysql5.5/etc/lyq314.cnf --basedir=/usr/local/mysql5.5/ --datadir=/home/mysql/data --user=mysql


5、添加環境變量


[root@ www.linuxidc.com ~]# echo "export PATH=$PATH:/usr/local/mysql5.5/bin" >> /etc/profile

[root@ www.linuxidc.com ~]# source /etc/profile


6、mysql的啓動


/usr/local/mysql5.5/bin/mysqld_safe --defaults-file=/usr/local/mysql5.5/etc/lyq314.cnf --datadir=/home/mysql/data --user=mysql &


7、查看mysql服務端口


# netstat -tunlp

[root@localhost etc]# netstat -nltp |grep 3306

tcp    00    0.0.0.0:3306    0.0.0.0:*    LISTEN24752/mysqld


8、設置管理員密碼


/usr/local/mysql5.5/bin/mysqladmin -u root password '1q2w3e4r'

#/usr/local/mysql5.5/bin/mysqladmin -u root -p1q2w3e4r  password '123456'


9、登陸數據庫進行測試


[root@ www.linuxidc.com mysql-5.5.30]# /usr/local/mysql5.5/bin/mysql -uroot -p

Enter password:

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

Your MySQL connection id is 11

Server version: 5.5.30-log Source distribution

Copyright (c) 2000, 2013, 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.02 sec)

mysql>


10、MySQL 的關閉


[root@ www.linuxidc.com mysql-5.5.30]# /usr/local/mysql5.5/bin/mysqladmin  -uroot -p shutdown

Enter password:

130717 00:31:09 mysqld_safe mysqld from pid file /home/mysql/data/lyq314.pid ended





本篇文章來源於 Linux公社網站(www.linuxidc.com)  原文鏈接:http://www.linuxidc.com/Linux/2013-07/87928.htm


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章