标签:mysql
1、安装相关依赖包
yum -y install gcc* autoconf automake zlib* fiex* libxml* ncurses-devel libmcrypt* libmcrypt* libtool-ltdl-devel*
2、需要安装个包
安装cmake
root@localhost src]# tar zxvf cmake-2.8.5.tar.gz
[root@localhost src]# cd cmake-2.8.5
[root@localhost cmake-2.8.5]# ./bootstrap
…… ……
-- Build files have been written to: /usr/local/src/cmake-2.8.5
---------------------------------------------
CMake has bootstrapped. Now run gmake.
[root@localhost 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
[root@localhost cmake-2.8.5]# gmake install
[root@localhost cmake-2.8.5]# cd ..
安装mysql5.7.11
[root@localhost src]# groupadd mysql
[root@localhost src]# useradd -g mysql mysql
[root@localhost src]# tar zxvf mysql-5.7.11.tar.gz
[root@localhost src]# cd mysql-5.7.11
[root@localhost 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
[root@localhost 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
[root@localhost 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
[root@localhost mysql-5.7.11]# chmod +w /usr/local/mysql/
[root@localhost mysql-5.7.11]# chown -R mysql:mysql /usr/local/mysql/
[root@localhost mysql-5.7.11]# ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib/libmysqlclient.so.18
[root@localhost mysql-5.7.11]# mkdir -p /var/mysql
[root@localhost mysql-5.7.11]# mkdir -p /var/mysql/log/
[root@localhost mysql-5.7.11]# chown -R mysql:mysql /var/mysql/
[root@localhost mysql-5.7.11]# cd support-files/
[root@localhost support-files]# cp my-medium.cnf /etc/my.cnf
[root@localhost support-files]# cp mysql.server /etc/init.d/mysql
[root@localhost 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:
[root@localhost 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!
[root@localhost support-files]# chmod +x /etc/init.d/mysql
[root@localhost support-files]# vi /etc/init.d/mysql
basedir=/usr/local/mysql
datadir=/var/mysql/data
[root@localhost support-files]#chkconfig --add mysql
[root@localhost support-files]#chkconfig --level 345 mysql on
[root@localhost support-files]# cd /usr/local/mysql
[root@localhost mysql]# service mysql start
Starting MySQL.. SUCCESS!
[root@localhost mysql]# mysql
-bash: mysql: command not found
[root@localhost 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
[root@localhost mysql]# ln -s /usr/local/mysql/bin/mysql /usr/bin
[root@localhost mysql]#ln -s /usr/local/mysql/bin/mysqladmin /usr/bin
[root@localhost 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 root@‘%‘ 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
[root@localhost 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” 博客,转载请与作者联系!
标签:mysql
原文地址:http://zhoukeda.blog.51cto.com/7741297/1845283