centos6.5编译安装mysql5.7.11
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了centos6.5编译安装mysql5.7.11相关的知识,希望对你有一定的参考价值。
1、安装相关依赖包
yum -y install gcc* autoconf automake zlib* fiex* libxml* ncurses-devel libmcrypt* libmcrypt* libtool-ltdl-devel*
2、需要安装个包
安装cmake
[email protected] src]# tar zxvf cmake-2.8.5.tar.gz
[[email protected] src]# cd cmake-2.8.5
[[email protected] cmake-2.8.5]# ./bootstrap
…… ……
-- Build files have been written to: /usr/local/src/cmake-2.8.5
---------------------------------------------
CMake has bootstrapped. Now run gmake.
[[email protected] cmake-2.8.5]# gmake
…… ……
[100%] Building CXX object Tests/CMakeLib/CMakeFiles/runcompilecommands.dir/run_compile_commands.cxx.o
Linking CXX executable runcompilecommands
[100%] Built target runcompilecommands
[[email protected] cmake-2.8.5]# gmake install
[[email protected] cmake-2.8.5]# cd ..
安装mysql5.7.11
[[email protected] src]# groupadd mysql
[[email protected] src]# useradd -g mysql mysql
[[email protected] src]# tar zxvf mysql-5.7.11.tar.gz
[[email protected] src]# cd mysql-5.7.11
[[email protected] mysql-5.7.11]#
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DEXTRA_CHARSETS=all \
-DWITH_EXTRA_CHARSETS:STRING=utf8,gbk \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_DATADIR=/var/mysql/data \
-DMYSQL_USER=mysql \
-DDOWNLOAD_BOOST=1 \
-DWITH_BOOST=/usr/local/boost/boost_1_59_0
…… ……
CMake Warning:
Manually-specified variables were not used by the project:
MYSQL_USER
WITH_MEMORY_STORAGE_ENGINE
-- Build files have been written to: /usr/local/src/mysql-5.7.11
[[email protected] mysql-5.7.11]#make
…… ……
[100%] Building CXX object mysql-test/lib/My/SafeProcess/CMakeFiles/my_safe_process.dir/safe_process.cc.o
Linking CXX executable my_safe_process
[100%] Built target my_safe_process
[[email protected] mysql-5.7.11]#make install
…… ……
-- Installing: /usr/local/mysql/man/man1/mysql_find_rows.1
-- Installing: /usr/local/mysql/man/man1/mysql_upgrade.1
-- Installing: /usr/local/mysql/man/man1/mysqlimport.1
-- Installing: /usr/local/mysql/man/man1/mysql_client_test.1
-- Installing: /usr/local/mysql/man/man8/mysqld.8
[[email protected] mysql-5.7.11]# chmod +w /usr/local/mysql/
[[email protected] mysql-5.7.11]# chown -R mysql:mysql /usr/local/mysql/
[[email protected] mysql-5.7.11]# ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib/libmysqlclient.so.18
[[email protected] mysql-5.7.11]# mkdir -p /var/mysql
[[email protected] mysql-5.7.11]# mkdir -p /var/mysql/log/
[[email protected] mysql-5.7.11]# chown -R mysql:mysql /var/mysql/
[[email protected] mysql-5.7.11]# cd support-files/
[[email protected] support-files]# cp my-medium.cnf /etc/my.cnf
[[email protected] support-files]# cp mysql.server /etc/init.d/mysql
[[email protected] support-files]# vim /etc/my.cnf
[mysqld] # Remove leading # and set to the amount of RAM for the most important data # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%. # innodb_buffer_pool_size = 128M # Remove leading # to turn on a very important data integrity option: logging # changes to the binary log between backups. #log_bin=mysql-bin # These are commonly set, remove the # and set as required. basedir = /usr/local/mysql datadir = /var/mysql/data port = 3306 # server_id = ..... socket = /tmp/mysql.sock #defaults-file=/etc/my.cnf explicit_defaults_for_timestamp=true
初始化mysql:
[[email protected] support-files]# /usr/local/mysql/bin/mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/var/mysql/data
You can start the MySQL daemon with:
cd /usr/local/mysql ; /usr/local/mysql/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd /usr/local/mysql/mysql-test ; perl mysql-test-run.pl
Please report any problems with the /usr/local/mysql/scripts/mysqlbug script!
[[email protected] support-files]# chmod +x /etc/init.d/mysql
[[email protected] support-files]# vi /etc/init.d/mysql
basedir=/usr/local/mysql
datadir=/var/mysql/data
[[email protected] support-files]#chkconfig --add mysql
[[email protected] support-files]#chkconfig --level 345 mysql on
[[email protected] support-files]# cd /usr/local/mysql
[[email protected] mysql]# service mysql start
Starting MySQL.. SUCCESS!
[[email protected] mysql]# mysql
-bash: mysql: command not found
[[email protected] mysql]# /usr/local/mysql/bin/mysql -uroot mysql
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.01 sec)
mysql> exit
Bye
[[email protected] mysql]# ln -s /usr/local/mysql/bin/mysql /usr/bin
[[email protected] mysql]#ln -s /usr/local/mysql/bin/mysqladmin /usr/bin
[[email protected] mysql]# mysql
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.00 sec)
mysql> grant all privileges on *.* to [email protected]‘%‘ identified by ‘123456‘ with grant option;
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> exit
Bye
[[email protected] mysql]# /etc/init.d/iptables stop;
Flushing firewall rules: [ OK ]
Setting chains to policy ACCEPT: filter [ OK ]
Unloading iptables modules: [ OK ]
开启端口3306的访问:
sbin/iptables -I INPUT -p tcp --dport 3306 -j ACCEPT
service iptables save
本文出自 “Mrzhou” 博客,转载请与作者联系!
以上是关于centos6.5编译安装mysql5.7.11的主要内容,如果未能解决你的问题,请参考以下文章
mysql5.7.11 源码编译安装 (Red hat linux 6.5 )