MYSQL5.5編譯安裝

MYSQL5.5編譯步驟10.10.54.66

mysql-5.5.30.tar.gz

卸載方法:
rm -fr /data/*
rm -fr /usr/local/mysql/ 刪除mysql下全部內容
rm -rf /soft/mysql-5.5.30
tar -xf mysql-5.5.30.tar.gz



1.安裝依賴文件
yum install -y cmake.x86_64

2.建立mysql用戶
有:
[root@tech03 softs]# cat /etc/passwd|grep mysql
mysql:x:501:501::/home/mysql:/sbin/nologin
沒有時:
[root@gyf  mysql-5.5.30]# groupadd mysql
[root@gyf  mysql-5.5.30]# useradd -g mysql mysql

3.編譯參數cmake編譯

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \......自動建立的權限是root
-DMYSQL_DATADIR=/data/dbdata \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DMYSQL_UNIX_ADDR=/usr/local/mysql/tmp/mysql.sock \
-DMYSQL_TCP_PORT=3306 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_EXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_SSL=yes

-DCMAKE_INSTALL_PREFIX=/usr/local/mysql:MySQL安裝目錄,推薦安裝到此目錄
-DWITH_INNOBASE_STORAGE_ENGINE=1:安裝InnoDB存儲引擎
-DWITH_MYISAM_STORAGE_ENGINE=1:安裝MyISAM存儲引擎
-DWITH_MEMORY_STORAGE_ENGINE=1:安裝內存存儲引擎
-DDEFAULT_CHARSET=utf8:默認編碼設置成utf8
-DDEFAULT_COLLATION=utf8_general_ci:默然校驗規則是utf8_general_ci
-DWITH_EXTRA_CHARSETS=all:支持其餘全部的編碼
-DMYSQL_TCP_PORT=3306:MySQL端口指定爲3306
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock:指定SOCK文件









CMake Error: your CXX compiler: "CMAKE_CXX_COMPILER-NOTFOUND" was not found.   Please set CMAKE_CXX_COMPILER to a valid compiler path or name.
-- MySQL 5.5.30
-- Packaging as: mysql-5.5.30-Linux-x86_64
-- Could NOT find Curses  (missing:  CURSES_LIBRARY CURSES_INCLUDE_PATH)
CMake Error at cmake/readline.cmake:83 (MESSAGE):
  Curses library not found.  Please install appropriate package,

清除緩存:rm CMakeCache.txt。。。。編譯後生成的文件
solution:
[root@tech2 mysql-5.1.70]# yum install ncurses-devel.x86_64 -y









CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage



solution:
yum -y install gcc-c++.x86_64 compat-gcc-34.x86_64
rm CMakeCache.txt

make
make install


4
##.建立目錄
mkdir -p /data/dbdata
chown mysql.mysql /usr/local/mysql -R
級聯修改目錄用戶和用戶組爲mysql
chown mysql.mysql /data/dbdata -R



5.複製mysql配置文件my.cnf
---window配置文件my.ini


 cp /soft/mysql-5.5.30/support-files/my-large.cnf /etc/my.cnf

6.複製啓動腳本
 cp /soft/mysql-5.5.30/support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld

7.初始化數據庫文件


[root@tech03 dbdata]# /usr/local/mysql/scripts/mysql_install_db --user=mysql

FATAL ERROR: Could not find ./bin/my_print_defaults

If you compiled from source, you need to run 'make install' to
copy the software into the correct location ready for operation.

If you are using a binary release, you must either be at the top
level of the extracted archive, or pass the --basedir option
pointing to that location.

解決方式:
/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql/
啓動數據庫
[root@gyf  dbdata]# /etc/init.d/mysqld start
err:
Starting MySQL.. ERROR! The server quit without updating PID file (/data/dbdata/gyf.pid).


[root@learn  data]# /etc/init.d/mysqld restart
 ERROR! MySQL server PID file could not be found!
Starting MySQL.. ERROR! The server quit without updating PID file (/data/dbdata/learn.pid).
[root@learn  data]# netstat -ntulp
[root@learn  data]# kill -9 1243
[root@gyf  dbdata]# vim /etc/my.cnf

[mysqld]
datadir=/data/mysql
#skip-locking

//在/etc/my.cnf配置文件添加:
[mysqld]
innodb_file_per_table=1
skip-name-resolve
long_query_time=0.5
slow_query_log
lower_case_table_names=1

[mysql]
prompt = \\u@\\d \\R:\\m>

8.修改用戶登陸密碼

/usr/local/mysql/bin/mysqladmin -u root password 'mysql'
################################

mysql

相關文章
相關標籤/搜索