源碼編譯cmake安裝mysql-5.5.32

源碼編譯cmake安裝mysql-5.5.32

[root@localhost ~]# 
[root@localhost ~]# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:0C:29:E8:0B:38  
          inet addr:192.168.70.134  Bcast:192.168.70.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fee8:b38/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:8036 errors:0 dropped:0 overruns:0 frame:0
          TX packets:5266 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:6232819 (5.9 MiB)  TX bytes:544874 (532.1 KiB)
[root@localhost ~]#
[root@localhost ~]# uname -a
Linux localhost.localdomain 2.6.32-504.16.2.el6.x86_64 #1 SMP Wed Apr 22 06:48:29 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
[root@localhost ~]# 
[root@localhost ~]# uname -r
2.6.32-504.16.2.el6.x86_64
[root@localhost ~]# 
[root@localhost ~]# cat /etc/redhat-release 
CentOS release 6.6 (Final)
[root@localhost ~]# 
[root@localhost ~]# cd /usr/local/src/

下載cmake、mysql源碼包
[root@localhost src]# ll
total 29580
-rw-r--r--. 1 root root  5691656 Apr 14 13:42 cmake-2.8.8.tar.gz
-rw-r--r--. 1 root root 24596474 Apr 14 13:44 mysql-5.5.32.tar.gz
[root@localhost src]# 

[root@localhost src]# tar -zxvf cmake-2.8.8.tar.gz 

[root@localhost src]# echo $?
0
[root@localhost src]# cd cmake-2.8.8

[root@localhost cmake-2.8.8]# yum install gcc gcc-c++


[root@localhost cmake-2.8.8]# ./configure 

[root@localhost cmake-2.8.8]# gmake &&gmake install

[root@localhost cmake-2.8.8]# cd ..

[root@localhost src]# tar -xf mysql-5.5.32.tar.gz 
[root@localhost src]# 
[root@localhost src]# cd mysql-5.5.32
[root@localhost mysql-5.5.32]# groupadd mysql

[root@localhost mysql-5.5.32]# useradd mysql -g mysql -M -s /sbin/nologin 
[root@localhost mysql-5.5.32]# 

[root@localhost mysql-5.5.32]# echo 'export PATH=/application/mysql/bin:$PATH >/etc/profile

[root@localhost mysql-5.5.32]# tail -l /etc/profile

[root@localhost mysql-5.5.32]# souce /etc/profile

[root@localhost mysql-5.5.32]#

[root@localhost mysql-5.5.32]# mkdir -p /application/mysql /application/mysql/data

[root@localhost mysql-5.5.32]# yum install   -y   ncurses  ncurses-devel

[root@localhost mysql-5.5.32]# rm -rf CMakeCache.txt 

[root@localhost mysql-5.5.32]# 

cmake . -DCMAKE_INSTALL_PREFIX=/application/mysql -DMYSQL_DATADIR=/application/mysql -DMYSQL_UNIX_ADDR=/application/mysql/tmp/mysql.sock -DEXTRA_CHARSETS=gbk,gb2312,utf8,ascii -DENABLED_LOCAL_INFILE=1 -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_FAST_MUTEXES=1 -DWITH_ZLIB=bundled -DENABLED_LOCAL_LNFILE=1 -DWITH_READLINE=1 -DWITH_EMBEDDED_SERVER=1 -DWITH_DEBUG=0


[root@localhost mysql-5.5.32]# chmod 1777 /tmp
[root@localhost mysql-5.5.32]# chown -R mysql.mysql /application/mysql/

[root@localhost mysql-5.5.32]# cp support-files/my-small.cnf /etc/my.cnf 
cp: overwrite `/etc/my.cnf'? y
[root@localhost mysql-5.5.32]# 

[root@localhost mysql-5.5.32]# cd /application/mysql/scripts/
[root@localhost scripts]# ./mysql_install_db --user=mysql --basedir=/application/mysql/ --datadir=/application/mysql/data/ &
[1] 30955
[root@localhost scripts]# Installing MySQL system tables...
OK
Filling help tables...                                       //表示成功
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

/application/mysql//bin/mysqladmin -u root password 'new-password'
/application/mysql//bin/mysqladmin -u root -h localhost.localdomain password 'new-password'

Alternatively you can run:
/application/mysql//bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd /application/mysql/ ; /application/mysql//bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd /application/mysql//mysql-test ; perl mysql-test-run.pl

Please report any problems with the /application/mysql//scripts/mysqlbug script!


[root@localhost scripts]# cp /usr/local/src/mysql-5.5.32/support-files/mysql.server /etc/init.d/mysqld

[root@localhost scripts]# chmod +x /etc/init.d/mysqld 

[root@localhost scripts]# /etc/init.d/mysqld start

報錯:

[root@localhost scripts]# /etc/init.d/mysqld start
Starting MySQL.. ERROR! The server quit without updating PID file (/application/mysql/localhost.localdomain.pid).
[root@localhost scripts]# 

[root@localhost scripts]# cat
150506 23:12:36 mysqld_safe Starting mysqld daemon with databases from /application/mysql
/application/mysql/bin/mysqld: Table 'mysql.plugin' doesn't exist
150506 23:12:36 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
150506 23:12:36 InnoDB: The InnoDB memory heap is disabled
150506 23:12:36 InnoDB: Mutexes and rw_locks use GCC atomic builtins
150506 23:12:36 InnoDB: Compressed tables use zlib 1.2.3
150506 23:12:36 InnoDB: Initializing buffer pool, size = 128.0M
150506 23:12:36 InnoDB: Completed initialization of buffer pool
150506 23:12:36 InnoDB: highest supported file format is Barracuda.
InnoDB: Log scan progressed past the checkpoint lsn 48941
150506 23:12:36  InnoDB: Database was not shut down normally!
InnoDB: Starting crash recovery.
InnoDB: Reading tablespace information from the .ibd files...
InnoDB: Restoring possible half-written data pages from the doublewrite
InnoDB: buffer...
InnoDB: Doing recovery: scanned up to log sequence number 1595675
150506 23:12:36  InnoDB: Starting an apply batch of log records to the database...
InnoDB: Progress in percents: 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 
InnoDB: Apply batch completed
150506 23:12:36  InnoDB: Waiting for the background threads to start
150506 23:12:37 InnoDB: 5.5.32 started; log sequence number 1595675
150506 23:12:37 [Note] Server hostname (bind-address): '0.0.0.0'; port: 3306
150506 23:12:37 [Note]   - '0.0.0.0' resolves to '0.0.0.0';
150506 23:12:37 [Note] Server socket created on IP: '0.0.0.0'.
150506 23:12:37 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist
150506 23:12:37 mysqld_safe mysqld from pid file /application/mysql/localhost.localdomain.pid ended
[root@localhost scripts]# 

查看是否有其他mysql數據庫已經安裝並使用了3306端口

[root@localhost scripts]# ps aux|grep mysql*

[root@localhost scripts]# rpm -qa|egrep mysql

查看 /etc/my.cnf 

[root@localhost application]# vi /etc/my.cnf 

更改配置文件,添加下面的內容:

[mysqld]

datadir=/application/mysql/data

然後重新啓動數據庫:

/etc/init.d/mysqld start

如果還不行,查看日誌文件確定問題。

 



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