安装mysql-5.6.43

Posted djlsunshine

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了安装mysql-5.6.43相关的知识,希望对你有一定的参考价值。

卸载老版本的mysql。查找并删除mysql有关的文件

# find / -name mysql

# rm -rf /usr/lib64/mysql /usr/share/mysql

[[email protected] ~]# find / -name mysql
/usr/lib64/mysql
/usr/share/mysql
[[email protected] ~]# rm -rf /usr/lib64/mysql /usr/share/mysql
[[email protected] ~]# 

上传mysql安装包并解压

# tar -zxf mysql-5.6.43-linux-glibc2.12-x86_64.tar.gz

[[email protected] ~]# ls
anaconda-ks.cfg  mysql-5.6.43-linux-glibc2.12-x86_64.tar.gz
[[email protected] ~]# tar -zxf mysql-5.6.43-linux-glibc2.12-x86_64.tar.gz 
[[email protected] ~]# ls
anaconda-ks.cfg                      mysql-5.6.43-linux-glibc2.12-x86_64.tar.gz
mysql-5.6.43-linux-glibc2.12-x86_64

选择安装位置并重命名

mv mysql-5.6.43-linux-glibc2.12-x86_64 /usr/mysql-5.6.43

[[email protected] ~]# mv mysql-5.6.43-linux-glibc2.12-x86_64 /usr/mysql-5.6.43
[[email protected] ~]# 
[[email protected] ~]# ls
anaconda-ks.cfg  mysql-5.6.43-linux-glibc2.12-x86_64.tar.gz
[[email protected] ~]# 
[[email protected] ~]# ls /usr/
bin  etc  games  include  lib  lib64  libexec  local  mysql-5.6.43  sbin  share  src  tmp

添加用户组和用户

# groupadd mysql

# useradd mysql -g mysql

# groups mysql

[[email protected] ~]# groupadd mysql
[[email protected] ~]# useradd mysql -g mysql
[[email protected] ~]# groups mysql
mysql : mysql

更改MySQL目录权限,进入mysql目录

[[email protected] ~]# cd /usr/mysql-5.6.43/
[[email protected] mysql-5.6.43]# 
[[email protected] mysql-5.6.43]# ls
bin  COPYING  data  docs  include  lib  man  mysql-test  README  scripts  share  sql-bench  support-files
[[email protected] mysql-5.6.43]# 
[[email protected] mysql-5.6.43]# pwd
/usr/mysql-5.6.43
[[email protected] mysql-5.6.43]# chown -R mysql:mysql /usr/mysql-5.6.43
[[email protected] mysql-5.6.43]# ll
total 52
drwxr-xr-x.  2 mysql mysql  4096 May 22 19:20 bin
-rw-r--r--.  1 mysql mysql 17987 Dec 21 15:46 COPYING
drwxr-xr-x.  3 mysql mysql    17 May 22 19:20 data
drwxr-xr-x.  2 mysql mysql    52 May 22 19:20 docs
drwxr-xr-x.  3 mysql mysql  4096 May 22 19:20 include
drwxr-xr-x.  3 mysql mysql  4096 May 22 19:20 lib
drwxr-xr-x.  4 mysql mysql    28 May 22 19:20 man
drwxr-xr-x. 10 mysql mysql  4096 May 22 19:20 mysql-test
-rw-r--r--.  1 mysql mysql  2496 Dec 21 15:46 README
drwxr-xr-x.  2 mysql mysql    29 May 22 19:20 scripts
drwxr-xr-x. 28 mysql mysql  4096 May 22 19:20 share
drwxr-xr-x.  4 mysql mysql  4096 May 22 19:20 sql-bench
drwxr-xr-x.  2 mysql mysql  4096 May 22 19:20 support-files

安装相关的包

# yum -y install perl perl-devel autoconf -y

Installed:
  perl-devel.x86_64 4:5.16.3-294.el7_6

Dependency Installed:
  gdbm-devel.x86_64 0:1.10-8.el7                     libdb-devel.x86_64 0:5.3.21-24.el7              perl-ExtUtils-Install.noarch 0:1.58-294.el7_6       perl-ExtUtils-MakeMaker.noarch 0:6.68-3.el7
  perl-ExtUtils-Manifest.noarch 0:1.61-244.el7       perl-ExtUtils-ParseXS.noarch 1:3.18-3.el7       pyparsing.noarch 0:1.5.6-9.el7                      systemtap-sdt-devel.x86_64 0:3.3-3.el7

Updated:
  perl.x86_64 4:5.16.3-294.el7_6

Dependency Updated:
  libdb.x86_64 0:5.3.21-24.el7                                   libdb-utils.x86_64 0:5.3.21-24.el7                                   perl-libs.x86_64 4:5.16.3-294.el7_6

Complete!

 

数据库初始化

# ./mysql_install_db --basedir=/usr/mysql-5.6.43/ --datadir=/usr/mysql-5.6.43/data/ --user=mysql

[[email protected] ~]# cd /usr/mysql-5.6.43/
[[email protected] mysql-5.6.43]#
[[email protected] mysql-5.6.43]#
[[email protected] mysql-5.6.43]# ls
bin  COPYING  data  docs  include  lib  man  mysql-test  README  scripts  share  sql-bench  support-files
[[email protected] mysql-5.6.43]#
[[email protected] mysql-5.6.43]#
[[email protected] mysql-5.6.43]# cd scripts/
[[email protected] scripts]#
[[email protected] scripts]#
[[email protected] scripts]# ls
mysql_install_db
[[email protected] scripts]#
[[email protected] scripts]#
[[email protected] scripts]# ll
total 36
-rwxr-xr-x. 1 mysql mysql 34558 Dec 21 16:10 mysql_install_db
[[email protected] scripts]#
[[email protected] scripts]#
[[email protected] scripts]# ./mysql_install_db --basedir=/usr/mysql-5.6.43/ --datadir=/usr/mysql-5.6.43/data/ --user=mysql
Installing MySQL system tables...2019-05-24 20:01:00 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2019-05-24 20:01:00 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
2019-05-24 20:01:00 0 [Note] /usr/mysql-5.6.43//bin/mysqld (mysqld 5.6.43) starting as process 7286 ...
2019-05-24 20:01:00 7286 [Note] InnoDB: Using atomics to ref count buffer pool pages
2019-05-24 20:01:00 7286 [Note] InnoDB: The InnoDB memory heap is disabled
2019-05-24 20:01:00 7286 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2019-05-24 20:01:00 7286 [Note] InnoDB: Memory barrier is not used
2019-05-24 20:01:00 7286 [Note] InnoDB: Compressed tables use zlib 1.2.11
2019-05-24 20:01:00 7286 [Note] InnoDB: Using Linux native AIO
2019-05-24 20:01:00 7286 [Note] InnoDB: Using CPU crc32 instructions
2019-05-24 20:01:01 7286 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2019-05-24 20:01:01 7286 [Note] InnoDB: Completed initialization of buffer pool
2019-05-24 20:01:01 7286 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2019-05-24 20:01:01 7286 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2019-05-24 20:01:01 7286 [Note] InnoDB: Database physically writes the file full: wait...
2019-05-24 20:01:01 7286 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2019-05-24 20:01:02 7286 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2019-05-24 20:01:05 7286 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2019-05-24 20:01:05 7286 [Warning] InnoDB: New log files created, LSN=45781
2019-05-24 20:01:05 7286 [Note] InnoDB: Doublewrite buffer not found: creating new
2019-05-24 20:01:05 7286 [Note] InnoDB: Doublewrite buffer created
2019-05-24 20:01:05 7286 [Note] InnoDB: 128 rollback segment(s) are active.
2019-05-24 20:01:05 7286 [Warning] InnoDB: Creating foreign key constraint system tables.
2019-05-24 20:01:06 7286 [Note] InnoDB: Foreign key constraint system tables created
2019-05-24 20:01:06 7286 [Note] InnoDB: Creating tablespace and datafile system tables.
2019-05-24 20:01:06 7286 [Note] InnoDB: Tablespace and datafile system tables created.
2019-05-24 20:01:06 7286 [Note] InnoDB: Waiting for purge to start
2019-05-24 20:01:06 7286 [Note] InnoDB: 5.6.43 started; log sequence number 0
2019-05-24 20:01:06 7286 [Note] Binlog end
2019-05-24 20:01:06 7286 [Note] InnoDB: FTS optimize thread exiting.
2019-05-24 20:01:06 7286 [Note] InnoDB: Starting shutdown...
2019-05-24 20:01:08 7286 [Note] InnoDB: Shutdown completed; log sequence number 1625977
OK

Filling help tables...2019-05-24 20:01:08 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2019-05-24 20:01:08 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
2019-05-24 20:01:08 0 [Note] /usr/mysql-5.6.43//bin/mysqld (mysqld 5.6.43) starting as process 7327 ...
2019-05-24 20:01:08 7327 [Note] InnoDB: Using atomics to ref count buffer pool pages
2019-05-24 20:01:08 7327 [Note] InnoDB: The InnoDB memory heap is disabled
2019-05-24 20:01:08 7327 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2019-05-24 20:01:08 7327 [Note] InnoDB: Memory barrier is not used
2019-05-24 20:01:08 7327 [Note] InnoDB: Compressed tables use zlib 1.2.11
2019-05-24 20:01:08 7327 [Note] InnoDB: Using Linux native AIO
2019-05-24 20:01:08 7327 [Note] InnoDB: Using CPU crc32 instructions
2019-05-24 20:01:08 7327 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2019-05-24 20:01:08 7327 [Note] InnoDB: Completed initialization of buffer pool
2019-05-24 20:01:08 7327 [Note] InnoDB: Highest supported file format is Barracuda.
2019-05-24 20:01:08 7327 [Note] InnoDB: 128 rollback segment(s) are active.
2019-05-24 20:01:08 7327 [Note] InnoDB: Waiting for purge to start
2019-05-24 20:01:08 7327 [Note] InnoDB: 5.6.43 started; log sequence number 1625977
2019-05-24 20:01:08 7327 [Note] Binlog end
2019-05-24 20:01:08 7327 [Note] InnoDB: FTS optimize thread exiting.
2019-05-24 20:01:08 7327 [Note] InnoDB: Starting shutdown...
2019-05-24 20:01:10 7327 [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/mysql-5.6.43//bin/mysqladmin -u root password ‘new-password‘
  /usr/mysql-5.6.43//bin/mysqladmin -u root -h localhost.localdomain password ‘new-password‘

Alternatively you can run:

  /usr/mysql-5.6.43//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/mysql-5.6.43//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/mysql-5.6.43//my.cnf and
will be used by default by the server when you start it.
You may edit this file to change server settings

WARNING: Default config file /etc/my.cnf exists on the system
This file will be read by default by the MySQL server
If you do not want to use this, either remove it, or use the
--defaults-file argument to mysqld_safe when starting the server

 

拷贝 my-default.cnf到/etc/my.cnf

# cd ../support-files/

# cp my-default.cnf /etc/my.cnf

[[email protected] scripts]# cd ../support-files/
[[email protected] support-files]#
[r[email protected] support-files]# ls
binary-configure  magic  my-default.cnf  mysqld_multi.server  mysql-log-rotate  mysql.server
[[email protected] support-files]#
[[email protected] support-files]# cp my-default.cnf /etc/my.cnf
cp: overwrite ‘/etc/my.cnf’? yes
[[email protected] support-files]#

 

向/etc/init.d中添加mysql的启动服务

init.d目录包含许多系统各种服务的启动和停止脚本。

[[email protected] support-files]# pwd
/usr/mysql-5.6.43/support-files
[[email protected] support-files]# ls
binary-configure  magic  my-default.cnf  mysqld_multi.server  mysql-log-rotate  mysql.server
[[email protected] support-files]# cp mysql.server /etc/init.d/mysqld
[[email protected] support-files]#

 

修改/etc/init.d/mysqld权限

# cd /etc/init.d/

# chmod 755 mysqld

[[email protected] support-files]# cd /etc/init.d/
[[email protected] init.d]#
[[email protected] init.d]# ls
functions  mysqld  netconsole  network  README
[[email protected] init.d]#
[[email protected] init.d]# chmod -R 755 mysqld
[[email protected] init.d]#
[[email protected] init.d]# ll
total 44
-rw-r--r--. 1 root root 13948 Sep 16  2015 functions
-rwxr-xr-x. 1 root root 10565 May 24 20:14 mysqld
-rwxr-xr-x. 1 root root  2989 Sep 16  2015 netconsole
-rwxr-xr-x. 1 root root  6630 Sep 16  2015 network
-rw-r--r--. 1 root root  1160 Nov 20  2015 README

修改/etc/init.d/mysqld

# vi /etc/init.d/mysqld

技术图片

配置环境变量

将MySQL配置到环境变量中,这样就可以在任何地方用mysql命令了

# vi /etc/profile

在最后添加

#mysql
export MYSQL_HOME=/usr/mysql-5.6.43
#PATH
export PATH=$MYSQL_HOME/bin:$PATH

 

执行如下指令,使上述配置立即生效

# source /etc/profile

启动MySQL

# /etc/init.d/mysqld start

[[email protected] ~]# /etc/init.d/mysqld start
Starting MySQL.Logging to /usr/mysql-5.6.43/data/localhost.localdomain.err.
................... SUCCESS!

 

查看err的信息

# cd /usr/mysql-5.6.43/data/

# cat localhost.localdomain.err

[[email protected] data]# cd /usr/mysql-5.6.43/data/
[[email protected] data]#
[[email protected] data]#
[[email protected] data]# ls
auto.cnf  ibdata1  ib_logfile0  ib_logfile1  localhost.localdomain.err  localhost.localdomain.pid  mysql  performance_schema  test
[[email protected] data]#
[[email protected] data]# cat localhost.localdomain.err
2019-05-24 20:37:02 7566 [Note] Plugin ‘FEDERATED‘ is disabled.
2019-05-24 20:37:02 7566 [Note] InnoDB: Using atomics to ref count buffer pool pages
2019-05-24 20:37:02 7566 [Note] InnoDB: The InnoDB memory heap is disabled
2019-05-24 20:37:02 7566 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2019-05-24 20:37:02 7566 [Note] InnoDB: Memory barrier is not used
2019-05-24 20:37:02 7566 [Note] InnoDB: Compressed tables use zlib 1.2.11
2019-05-24 20:37:02 7566 [Note] InnoDB: Using Linux native AIO
2019-05-24 20:37:02 7566 [Note] InnoDB: Using CPU crc32 instructions
2019-05-24 20:37:02 7566 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2019-05-24 20:37:02 7566 [Note] InnoDB: Completed initialization of buffer pool
2019-05-24 20:37:03 7566 [Note] InnoDB: Highest supported file format is Barracuda.
2019-05-24 20:37:04 7566 [Note] InnoDB: 128 rollback segment(s) are active.
2019-05-24 20:37:04 7566 [Note] InnoDB: Waiting for purge to start
2019-05-24 20:37:04 7566 [Note] InnoDB: 5.6.43 started; log sequence number 1625987
2019-05-24 20:37:04 7566 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: a27e1f65-7e20-11e9-9950-000c294cff47.
2019-05-24 20:37:04 7566 [Note] Server hostname (bind-address): *; port: 3306
2019-05-24 20:37:04 7566 [Note] IPv6 is available.
2019-05-24 20:37:04 7566 [Note]   - :: resolves to ::;
2019-05-24 20:37:04 7566 [Note] Server socket created on IP: ::.
2019-05-24 20:37:04 7566 [Note] Event Scheduler: Loaded 0 events
2019-05-24 20:37:04 7566 [Note] /usr/mysql-5.6.43/bin/mysqld: ready for connections.
Version: 5.6.43  socket: /tmp/mysql.sock  port: 3306  MySQL Community Server (GPL)

 

修改/etc/my.cnf

# vi /etc/my.cnf

添加federated

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. Its a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.

[mysqld]
federated
# 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

# These are commonly set, remove the # and set as required.
# basedir = .....
# datadir = .....
# port = .....
# server_id = .....
# socket = .....

# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

再次重新启动

[[email protected] ~]# /etc/init.d/mysqld stop
Shutting down MySQL.. SUCCESS!
[[email protected] ~]#
[[email protected] ~]#
[[email protected] ~]# /etc/init.d/mysqld start
Starting MySQL... SUCCESS!
[[email protected] ~]#
[[email protected] ~]# ps -aux | grep mysqld
root       7664  0.0  0.0 113248  1612 pts/0    S    20:46   0:00 /bin/sh /usr/mysql-5.6.43/bin/mysqld_safe --datadir=/usr/mysql-5.6.43/data --pid-file=/usr/mysql-5.6.43/data/localhost.localdomain.pid
mysql      7785  9.6 24.2 1302684 453160 pts/0  Sl   20:46   0:02 /usr/mysql-5.6.43/bin/mysqld --basedir=/usr/mysql-5.6.43 --datadir=/usr/mysql-5.6.43/data --plugin-dir=/usr/mysql-5.6.43/lib/plugin --user=mysql --log-error=localhost.localdomain.err --pid-file=/usr/mysql-5.6.43/data/localhost.localdomain.pid
root       7813  0.0  0.0 112644   952 pts/0    S+   20:46   0:00 grep --color=auto mysqld

登陆MySQL数据库

# mysql -uroot -p

[[email protected] ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \\g.
Your MySQL connection id is 1
Server version: 5.6.43 MySQL Community Server (GPL)

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type help; or \\h for help. Type \\c to clear the current input statement.

mysql> select user,host,password from mysql.user;
+------+-----------------------+----------+
| user | host                  | password |
+------+-----------------------+----------+
| root | localhost             |          |
| root | localhost.localdomain |          |
| root | 127.0.0.1             |          |
| root | ::1                   |          |
|      | localhost             |          |
|      | localhost.localdomain |          |
+------+-----------------------+----------+
6 rows in set (0.00 sec)

 

授权并设置root密码

mysql> update mysql.user set password=password(‘000000‘) where user=‘root‘ and host=‘localhost‘;

mysql> grant all privileges on *.* to [email protected]‘%‘ identified by ‘000000‘;

mysql> update mysql.user set password=password(000000) where user=root and host=localhost;
Query OK, 1 row affected (0.04 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> select user,host,password from mysql.user;
+------+-----------------------+-------------------------------------------+
| user | host                  | password                                  |
+------+-----------------------+-------------------------------------------+
| root | localhost             | *032197AE5731D4664921A6CCAC7CFCE6A0698693 |
| root | localhost.localdomain |                                           |
| root | 127.0.0.1             |                                           |
| root | ::1                   |                                           |
|      | localhost             |                                           |
|      | localhost.localdomain |                                           |
+------+-----------------------+-------------------------------------------+
6 rows in set (0.00 sec)

mysql> grant all privileges on *.* to [email protected]% identified by 000000;
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> select user,host,password from mysql.user;
+------+-----------------------+-------------------------------------------+
| user | host                  | password                                  |
+------+-----------------------+-------------------------------------------+
| root | localhost             | *032197AE5731D4664921A6CCAC7CFCE6A0698693 |
| root | localhost.localdomain |                                           |
| root | 127.0.0.1             |                                           |
| root | ::1                   |                                           |
|      | localhost             |                                           |
|      | localhost.localdomain |                                           |
| root | %                     | *032197AE5731D4664921A6CCAC7CFCE6A0698693 |
+------+-----------------------+-------------------------------------------+
7 rows in set (0.00 sec)

 

关闭防火墙客户端连接

技术图片

参考博客

https://www.cnblogs.com/dengshihuang/p/8029092.html

https://blog.csdn.net/qiushisoftware/article/details/86617699

Linux--Linux服务器数据库MySQL5.6.43版本安装过程说明(阿里云服务器)

https://blog.csdn.net/fumushan/article/details/87073240

阿里云CentOS安装mysql-5.6.43

https://blog.csdn.net/qiushisoftware/article/details/86617699

以上是关于安装mysql-5.6.43的主要内容,如果未能解决你的问题,请参考以下文章

源码编译安装lnmp环境(nginx-1.14.2 + mysql-5.6.43 + php-5.6.30 )------踩了无数坑,重装了十几次服务器才会的,不容易啊!

: mysql 5.6.34 编译安装 (centos7)

Linux下安装mysql

centos彻底卸载mysql(不保留数据)

138

mysql主从搭建