Mysql 5.6安装

一.下载地址:

搜狐镜像源:   http://mirrors.sohu.com/

官网下载:   https://downloads.mysql.com/archives/community/

本次实验主要版本为5.6

二.Mysql的安装方式

rpm包安装、yum安装、源码编译安装

三.编译安装Mysql5.6

3.1准备虚拟机 IP地址:192.168.1.190

root@localhost ~]# cat /etc/redhat-release 
CentOS Linux release 7.7.1908 (Core)

3.2关闭selinux,关闭防火墙

[root@localhost ~]# vi /etc/selinux/config 
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.

3.3 清除系统自带的mysql

userdel -r mysql
yum -y remove mariadb mariadb-libs mariadb-server mariadb-devel
rm -rf /etc/my*
rm -rf /var/lib/mysql
rm -rf /var/log/mysql*

3.4 安装依赖包

yum -y install make bison-devel ncures-devel libaio perl-Data-Dumper net-tools bison bison-devel gcc gcc-c++ cmake ncurses ncurses-developenssl openssl-devel curses-devel ncurses-devel

3.5创建mysql用户

root@localhost ~]# useradd -s /sbin/nologin mysql
[root@localhost ~]# id mysql
uid=1001(mysql) gid=1001(mysql) 组=1001(mysql)

3.6上传解压源码包

tar -zxvf mysql-5.6.49.tar.gz
[root@localhost soft]# cd mysql-5.6.49/
[root@localhost mysql-5.6.49]# ls
BUILD           config.h.cmake       extra      libservices  mysys_ssl  scripts           storage        VERSION
client          configure.cmake      include    LICENSE      packaging  source_downloads  strings        vio
cmake           dbug                 INSTALL    man          plugin     sql               support-files  win
CMakeLists.txt  Docs                 libmysql   mysql-test   README     sql-bench         tests          zlib
cmd-line-utils  Doxyfile-perfschema  libmysqld  mysys        regex      sql-common        unittest

3.7执行cmake

cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DSYSCONFDIR=/etc \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DEXTRA_CHARSETS=all \
-DWITH_EXTRA_CHARSETS=all \
-DWITH_INNODB_MEMCACHED=1 \
-DMYSQL_TCP_PORT=3306 \
-DWITH_DEBUG=1 \
-DWITH_EMBEDDED_SERVER=1 \
-DWITH_ZLIB=system \
-DWITH_BOOST=boost \
-DENABLED_LOCAL_INFILE=1 \
-DENABLED_PROFILING=ON \
-DWITH_SYSTEMD=1
----------------------------------------------参数解释---------------------------------------------------
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ mysql安装目录
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \ mysql.sock路径
-DSYSCONFDIR=/etc \ mysql配置文件目录
-DDEFAULT_CHARSET=utf8 \ 默认的字符集为utf8
-DDEFAULT_COLLATION=utf8_general_ci \ 默认排序规则
-DWITH_INNOBASE_STORAGE_ENGINE=1 \ 储存引擎
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \ 储存引擎
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \ 储存引擎
-DENABLE_LOCAL_INFILE=1 \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DMYSQL_DATADIR=/usr/local/mysql/data \ 数据库文件存放位置
-DEXTRA_CHARSETS=all \ 启用额外的字符集类型
-DMYSQL_TCP_PORT=3306 \ TCP端口
-DWITH_DEBUG=OFF \ 禁用debug
-DWITH_READLINE=1 \ 启用readline库支持(提供可编辑的命令行)
-DWITH_EMBEDDED_SERVER=1 \ 编译嵌入式服务器支持
-DWITH_ZLIB=system \ 启用libz库支持(zib、gzib相关)
-DENABLE_DTRACE=OFF \
-DWITH_BOOST=boost \ 指定boost
-DWITH_SYSTEMD=1 支持systemctl

编译后报错,这个地方缺啥包报错,就重新安装缺的哪个包,安装后要删除rm -f CMakeCache.txt这个文件,然后重新cmake

Cannot find appropriate system libraries for WITH_SSL=system.
Make sure you have specified a supported SSL version. 
Valid options are : 
system (use the OS openssl library), 
yes (synonym for system), 
</path/to/custom/openssl/installation>

CMake Error at cmake/ssl.cmake:66 (MESSAGE):
  Please install the appropriate openssl developer package.

Call Stack (most recent call first):
  cmake/ssl.cmake:260 (FATAL_SSL_NOT_FOUND_ERROR)
  CMakeLists.txt:483 (MYSQL_CHECK_SSL)

重新安装包

yum -y install openssl openssl-devel

删除文本

rm -f CMakeCache.txt

重新编译后完成

3.8 make&&make install

 

 

 

 

 

 3.9更改目录属性

[root@localhost ~]# cd /usr/local/
[root@localhost local]# ls
bin  etc  games  include  lib  lib64  libexec  mysql  sbin  share  src
[root@localhost local]# chown -R mysql:mysql mysql

3.10 初始化

/usr/local/mysql/scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data --basedir=/usr/local/mysql

[root@localhost soft]# /usr/local/mysql/scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data --basedir=/usr/local/mysql
Installing MySQL system tables...2022-04-06 06:35:17 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2022-04-06 06:35:17 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
2022-04-06 06:35:17 0 [Note] /usr/local/mysql/bin/mysqld (mysqld 5.6.49-debug) starting as process 76860 ...
2022-04-06 06:35:17 76860 [Note] InnoDB: Using atomics to ref count buffer pool pages
2022-04-06 06:35:17 7f9d1b8fe880 InnoDB: !!!!!!!! UNIV_DEBUG switched on !!!!!!!!!
2022-04-06 06:35:17 7f9d1b8fe880 InnoDB: !!!!!!!! UNIV_SYNC_DEBUG switched on !!!!!!!!!
2022-04-06 06:35:17 76860 [Note] InnoDB: The InnoDB memory heap is disabled
2022-04-06 06:35:17 76860 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2022-04-06 06:35:17 76860 [Note] InnoDB: Memory barrier is not used
2022-04-06 06:35:17 76860 [Note] InnoDB: Compressed tables use zlib 1.2.7
2022-04-06 06:35:17 76860 [Note] InnoDB: Using CPU crc32 instructions
2022-04-06 06:35:17 76860 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2022-04-06 06:35:17 76860 [Note] InnoDB: Completed initialization of buffer pool
2022-04-06 06:35:17 76860 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2022-04-06 06:35:17 76860 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2022-04-06 06:35:17 76860 [Note] InnoDB: Database physically writes the file full: wait...
2022-04-06 06:35:17 76860 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2022-04-06 06:35:17 76860 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2022-04-06 06:35:17 76860 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2022-04-06 06:35:17 76860 [Warning] InnoDB: New log files created, LSN=45781
2022-04-06 06:35:17 76860 [Note] InnoDB: Doublewrite buffer not found: creating new
2022-04-06 06:35:17 76860 [Note] InnoDB: Doublewrite buffer created
2022-04-06 06:35:18 76860 [Note] InnoDB: 128 rollback segment(s) are active.
2022-04-06 06:35:18 76860 [Warning] InnoDB: Creating foreign key constraint system tables.
2022-04-06 06:35:18 76860 [Note] InnoDB: Foreign key constraint system tables created
2022-04-06 06:35:18 76860 [Note] InnoDB: Creating tablespace and datafile system tables.
2022-04-06 06:35:18 76860 [Note] InnoDB: Tablespace and datafile system tables created.
2022-04-06 06:35:18 76860 [Note] InnoDB: Waiting for purge to start
2022-04-06 06:35:18 76860 [Note] InnoDB: 5.6.49 started; log sequence number 0
2022-04-06 06:35:18 76860 [Note] RSA private key file not found: /usr/local/mysql/data//private_key.pem. Some authentication plugins will not work.
2022-04-06 06:35:18 76860 [Note] RSA public key file not found: /usr/local/mysql/data//public_key.pem. Some authentication plugins will not work.
2022-04-06 06:35:18 76860 [Note] Binlog end
2022-04-06 06:35:18 76860 [Note] InnoDB: FTS optimize thread exiting.
2022-04-06 06:35:18 76860 [Note] InnoDB: Starting shutdown...
2022-04-06 06:35:19 76860 [Note] InnoDB: Shutdown completed; log sequence number 1625977
OK

Filling help tables...2022-04-06 06:35:19 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2022-04-06 06:35:19 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
2022-04-06 06:35:19 0 [Note] /usr/local/mysql/bin/mysqld (mysqld 5.6.49-debug) starting as process 76882 ...
2022-04-06 06:35:19 76882 [Note] InnoDB: Using atomics to ref count buffer pool pages
2022-04-06 06:35:19 7fd227ac2880 InnoDB: !!!!!!!! UNIV_DEBUG switched on !!!!!!!!!
2022-04-06 06:35:19 7fd227ac2880 InnoDB: !!!!!!!! UNIV_SYNC_DEBUG switched on !!!!!!!!!
2022-04-06 06:35:19 76882 [Note] InnoDB: The InnoDB memory heap is disabled
2022-04-06 06:35:19 76882 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2022-04-06 06:35:19 76882 [Note] InnoDB: Memory barrier is not used
2022-04-06 06:35:19 76882 [Note] InnoDB: Compressed tables use zlib 1.2.7
2022-04-06 06:35:19 76882 [Note] InnoDB: Using CPU crc32 instructions
2022-04-06 06:35:19 76882 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2022-04-06 06:35:19 76882 [Note] InnoDB: Completed initialization of buffer pool
2022-04-06 06:35:19 76882 [Note] InnoDB: Highest supported file format is Barracuda.
2022-04-06 06:35:20 76882 [Note] InnoDB: 128 rollback segment(s) are active.
2022-04-06 06:35:20 76882 [Note] InnoDB: Waiting for purge to start
2022-04-06 06:35:21 76882 [Note] InnoDB: 5.6.49 started; log sequence number 1625977
2022-04-06 06:35:21 76882 [Note] RSA private key file not found: /usr/local/mysql/data//private_key.pem. Some authentication plugins will not work.
2022-04-06 06:35:21 76882 [Note] RSA public key file not found: /usr/local/mysql/data//public_key.pem. Some authentication plugins will not work.
2022-04-06 06:35:22 76882 [Note] Binlog end
2022-04-06 06:35:22 76882 [Note] InnoDB: FTS optimize thread exiting.
2022-04-06 06:35:22 76882 [Note] InnoDB: Starting shutdown...
2022-04-06 06:35:23 76882 [Note] InnoDB: Shutdown completed; log sequence number 1625987
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:

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

Alternatively you can run:

  /usr/local/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 . ; /usr/local/mysql/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl

  cd mysql-test ; perl mysql-test-run.pl

Please report any problems at http://bugs.mysql.com/

The latest information about MySQL is available on the web at

  http://www.mysql.com

Support MySQL by buying support/licenses at http://shop.mysql.com

New default config file was created as /usr/local/mysql/my.cnf and
will be used by default by the server when you start it.
You may edit this file to change server settings


 

3.11 拷贝启动脚本

[root@localhost ~]# cd /usr/local/mysql/support-files/
[root@localhost support-files]# ls
binary-configure  magic  my-default.cnf  mysqld_multi.server  mysql-log-rotate  mysql.server
[root@localhost support-files]# cp mysql.server /etc/init.d/mysqld
[root@localhost support-files]# chmod 700 /etc/init.d/mysqld

 

3.12拷贝配置文件,(初始化的时候,必须用参数--defaults-file指定my.cnf,否则系统用默认的/etc/my.cnf)

[root@localhost support-files]# pwd
/usr/local/mysql/support-files
[root@localhost support-files]# cp my-default.cnf /etc/my.cnf

3.13配置环境变量

[root@localhost support-files]# vi /etc/profile
PATH=/usr/local/mysql/bin:$PATH

[root@localhost ~]# echo $PATH
/usr/local/mysql/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin

3.14启动mysql

[root@localhost support-files]# /etc/init.d/mysqld start
Starting MySQL.Logging to '/usr/local/mysql/data/localhost.localdomain.err'.
... SUCCESS!

 

posted @ 2022-04-05 22:37  中仕  阅读(44)  评论(0编辑  收藏  举报