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

# find / -name mysql

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

[root@localhost ~]# find / -name mysql
/usr/lib64/mysql
/usr/share/mysql
[root@localhost ~]# rm -rf /usr/lib64/mysql /usr/share/mysql
[root@localhost ~]#

上传mysql安装包并解压

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

[root@localhost ~]# ls
anaconda-ks.cfg mysql-5.6.-linux-glibc2.-x86_64.tar.gz
[root@localhost ~]# tar -zxf mysql-5.6.-linux-glibc2.-x86_64.tar.gz
[root@localhost ~]# ls
anaconda-ks.cfg mysql-5.6.-linux-glibc2.-x86_64.tar.gz
mysql-5.6.-linux-glibc2.-x86_64

选择安装位置并重命名

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

[root@localhost ~]# mv mysql-5.6.-linux-glibc2.-x86_64 /usr/mysql-5.6.
[root@localhost ~]#
[root@localhost ~]# ls
anaconda-ks.cfg mysql-5.6.-linux-glibc2.-x86_64.tar.gz
[root@localhost ~]#
[root@localhost ~]# ls /usr/
bin etc games include lib lib64 libexec local mysql-5.6. sbin share src tmp

添加用户组和用户

# groupadd mysql

# useradd mysql -g mysql

# groups mysql

[root@localhost ~]# groupadd mysql
[root@localhost ~]# useradd mysql -g mysql
[root@localhost ~]# groups mysql
mysql : mysql

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

[root@localhost ~]# cd /usr/mysql-5.6./
[root@localhost mysql-5.6.]#
[root@localhost mysql-5.6.]# ls
bin COPYING data docs include lib man mysql-test README scripts share sql-bench support-files
[root@localhost mysql-5.6.]#
[root@localhost mysql-5.6.]# pwd
/usr/mysql-5.6.
[root@localhost mysql-5.6.]# chown -R mysql:mysql /usr/mysql-5.6.
[root@localhost mysql-5.6.]# ll
total
drwxr-xr-x. mysql mysql May : bin
-rw-r--r--. mysql mysql Dec : COPYING
drwxr-xr-x. mysql mysql May : data
drwxr-xr-x. mysql mysql May : docs
drwxr-xr-x. mysql mysql May : include
drwxr-xr-x. mysql mysql May : lib
drwxr-xr-x. mysql mysql May : man
drwxr-xr-x. mysql mysql May : mysql-test
-rw-r--r--. mysql mysql Dec : README
drwxr-xr-x. mysql mysql May : scripts
drwxr-xr-x. mysql mysql May : share
drwxr-xr-x. mysql mysql May : sql-bench
drwxr-xr-x. mysql mysql May : support-files

安装相关的包

# yum install perl perl-devel autoconf -y

Installed:
perl-devel.x86_64 :5.16.-.el7_6 Dependency Installed:
gdbm-devel.x86_64 :1.10-.el7 libdb-devel.x86_64 :5.3.-.el7 perl-ExtUtils-Install.noarch :1.58-.el7_6 perl-ExtUtils-MakeMaker.noarch :6.68-.el7
perl-ExtUtils-Manifest.noarch :1.61-.el7 perl-ExtUtils-ParseXS.noarch :3.18-.el7 pyparsing.noarch :1.5.-.el7 systemtap-sdt-devel.x86_64 :3.3-.el7 Updated:
perl.x86_64 :5.16.-.el7_6 Dependency Updated:
libdb.x86_64 :5.3.-.el7 libdb-utils.x86_64 :5.3.-.el7 perl-libs.x86_64 :5.16.-.el7_6 Complete!

数据库初始化

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

[root@localhost ~]# cd /usr/mysql-5.6./
[root@localhost mysql-5.6.]#
[root@localhost mysql-5.6.]#
[root@localhost mysql-5.6.]# ls
bin COPYING data docs include lib man mysql-test README scripts share sql-bench support-files
[root@localhost mysql-5.6.]#
[root@localhost mysql-5.6.]#
[root@localhost mysql-5.6.]# cd scripts/
[root@localhost scripts]#
[root@localhost scripts]#
[root@localhost scripts]# ls
mysql_install_db
[root@localhost scripts]#
[root@localhost scripts]#
[root@localhost scripts]# ll
total
-rwxr-xr-x. mysql mysql Dec : mysql_install_db
[root@localhost scripts]#
[root@localhost scripts]#
[root@localhost scripts]# ./mysql_install_db --basedir=/usr/mysql-5.6./ --datadir=/usr/mysql-5.6./data/ --user=mysql
Installing MySQL system tables...-- :: [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
-- :: [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
-- :: [Note] /usr/mysql-5.6.//bin/mysqld (mysqld 5.6.43) starting as process 7286 ...
-- :: [Note] InnoDB: Using atomics to ref count buffer pool pages
-- :: [Note] InnoDB: The InnoDB memory heap is disabled
-- :: [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
-- :: [Note] InnoDB: Memory barrier is not used
-- :: [Note] InnoDB: Compressed tables use zlib 1.2.
-- :: [Note] InnoDB: Using Linux native AIO
-- :: [Note] InnoDB: Using CPU crc32 instructions
-- :: [Note] InnoDB: Initializing buffer pool, size = 128.0M
-- :: [Note] InnoDB: Completed initialization of buffer pool
-- :: [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
-- :: [Note] InnoDB: Setting file ./ibdata1 size to MB
-- :: [Note] InnoDB: Database physically writes the file full: wait...
-- :: [Note] InnoDB: Setting log file ./ib_logfile101 size to MB
-- :: [Note] InnoDB: Setting log file ./ib_logfile1 size to MB
-- :: [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
-- :: [Warning] InnoDB: New log files created, LSN=
-- :: [Note] InnoDB: Doublewrite buffer not found: creating new
-- :: [Note] InnoDB: Doublewrite buffer created
-- :: [Note] InnoDB: rollback segment(s) are active.
-- :: [Warning] InnoDB: Creating foreign key constraint system tables.
-- :: [Note] InnoDB: Foreign key constraint system tables created
-- :: [Note] InnoDB: Creating tablespace and datafile system tables.
-- :: [Note] InnoDB: Tablespace and datafile system tables created.
-- :: [Note] InnoDB: Waiting for purge to start
-- :: [Note] InnoDB: 5.6. started; log sequence number
-- :: [Note] Binlog end
-- :: [Note] InnoDB: FTS optimize thread exiting.
-- :: [Note] InnoDB: Starting shutdown...
-- :: [Note] InnoDB: Shutdown completed; log sequence number
OK Filling help tables...-- :: [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
-- :: [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
-- :: [Note] /usr/mysql-5.6.//bin/mysqld (mysqld 5.6.43) starting as process 7327 ...
-- :: [Note] InnoDB: Using atomics to ref count buffer pool pages
-- :: [Note] InnoDB: The InnoDB memory heap is disabled
-- :: [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
-- :: [Note] InnoDB: Memory barrier is not used
-- :: [Note] InnoDB: Compressed tables use zlib 1.2.
-- :: [Note] InnoDB: Using Linux native AIO
-- :: [Note] InnoDB: Using CPU crc32 instructions
-- :: [Note] InnoDB: Initializing buffer pool, size = 128.0M
-- :: [Note] InnoDB: Completed initialization of buffer pool
-- :: [Note] InnoDB: Highest supported file format is Barracuda.
-- :: [Note] InnoDB: rollback segment(s) are active.
-- :: [Note] InnoDB: Waiting for purge to start
-- :: [Note] InnoDB: 5.6. started; log sequence number
-- :: [Note] Binlog end
-- :: [Note] InnoDB: FTS optimize thread exiting.
-- :: [Note] InnoDB: Starting shutdown...
-- :: [Note] InnoDB: Shutdown completed; log sequence number
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.//bin/mysqladmin -u root password 'new-password'
/usr/mysql-5.6.//bin/mysqladmin -u root -h localhost.localdomain password 'new-password' Alternatively you can run: /usr/mysql-5.6.//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.//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.//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

[root@localhost scripts]# cd ../support-files/
[root@localhost 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]#
[root@localhost support-files]# cp my-default.cnf /etc/my.cnf
cp: overwrite ‘/etc/my.cnf’? yes
[root@localhost support-files]#

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

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

[root@localhost support-files]# pwd
/usr/mysql-5.6./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]#

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

# cd /etc/init.d/

# chmod 755 mysqld

[root@localhost support-files]# cd /etc/init.d/
[root@localhost init.d]#
[root@localhost init.d]# ls
functions mysqld netconsole network README
[root@localhost init.d]#
[root@localhost init.d]# chmod -R mysqld
[root@localhost init.d]#
[root@localhost init.d]# ll
total
-rw-r--r--. root root Sep functions
-rwxr-xr-x. root root May : mysqld
-rwxr-xr-x. root root Sep netconsole
-rwxr-xr-x. root root Sep network
-rw-r--r--. root root Nov README

修改/etc/init.d/mysqld

# vi /etc/init.d/mysqld

配置环境变量

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

# vi /etc/profile

在最后添加

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

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

# source /etc/profile

启动MySQL

# /etc/init.d/mysqld start

[root@localhost ~]# /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

[root@localhost data]# cd /usr/mysql-5.6./data/
[root@localhost data]#
[root@localhost data]#
[root@localhost data]# ls
auto.cnf ibdata1 ib_logfile0 ib_logfile1 localhost.localdomain.err localhost.localdomain.pid mysql performance_schema test
[root@localhost data]#
[root@localhost data]# cat localhost.localdomain.err
2019-05-24 20:37:02 7566 [Note] Plugin 'FEDERATED' is disabled.
-- :: [Note] InnoDB: Using atomics to ref count buffer pool pages
-- :: [Note] InnoDB: The InnoDB memory heap is disabled
-- :: [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
-- :: [Note] InnoDB: Memory barrier is not used
-- :: [Note] InnoDB: Compressed tables use zlib 1.2.
-- :: [Note] InnoDB: Using Linux native AIO
-- :: [Note] InnoDB: Using CPU crc32 instructions
-- :: [Note] InnoDB: Initializing buffer pool, size = 128.0M
-- :: [Note] InnoDB: Completed initialization of buffer pool
-- :: [Note] InnoDB: Highest supported file format is Barracuda.
-- :: [Note] InnoDB: rollback segment(s) are active.
-- :: [Note] InnoDB: Waiting for purge to start
-- :: [Note] InnoDB: 5.6. started; log sequence number
-- :: [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--000c294cff47.
-- :: [Note] Server hostname (bind-address): '*'; port:
-- :: [Note] IPv6 is available.
-- :: [Note] - '::' resolves to '::';
-- :: [Note] Server socket created on IP: '::'.
-- :: [Note] Event Scheduler: Loaded events
-- :: [Note] /usr/mysql-5.6./bin/mysqld: ready for connections.
Version: '5.6.43' socket: '/tmp/mysql.sock' port: 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. It's 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 % of total RAM for dedicated server, else %.
# 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

再次重新启动

[root@localhost ~]# /etc/init.d/mysqld stop
Shutting down MySQL.. SUCCESS!
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# /etc/init.d/mysqld start
Starting MySQL... SUCCESS!
[root@localhost ~]#
[root@localhost ~]# ps -aux | grep mysqld
root 0.0 0.0 pts/ S : : /bin/sh /usr/mysql-5.6./bin/mysqld_safe --datadir=/usr/mysql-5.6./data --pid-file=/usr/mysql-5.6./data/localhost.localdomain.pid
mysql 9.6 24.2 pts/ Sl : : /usr/mysql-5.6./bin/mysqld --basedir=/usr/mysql-5.6. --datadir=/usr/mysql-5.6./data --plugin-dir=/usr/mysql-5.6./lib/plugin --user=mysql --log-error=localhost.localdomain.err --pid-file=/usr/mysql-5.6./data/localhost.localdomain.pid
root 0.0 0.0 pts/ S+ : : grep --color=auto mysqld

登陆MySQL数据库

# mysql -uroot -p

[root@localhost ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is
Server version: 5.6. MySQL Community Server (GPL) Copyright (c) , , 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 | :: | |
| | localhost | |
| | localhost.localdomain | |
+------+-----------------------+----------+
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 root@'%' identified by '000000';

mysql> update mysql.user set password=password('') where user='root' and host='localhost';
Query OK, row affected (0.04 sec)
Rows matched: Changed: Warnings: mysql> flush privileges;
Query OK, 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 | :: | |
| | localhost | |
| | localhost.localdomain | |
+------+-----------------------+-------------------------------------------+
rows in set (0.00 sec) mysql> grant all privileges on *.* to root@'%' identified by '';
Query OK, rows affected (0.00 sec) mysql> flush privileges;
Query OK, 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 | :: | |
| | localhost | |
| | localhost.localdomain | |
| root | % | *032197AE5731D4664921A6CCAC7CFCE6A0698693 |
+------+-----------------------+-------------------------------------------+
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

centos7安装mysql-5.6.43二进制包的更多相关文章

  1. Centos7 安装MySQL 5.7 (通用二进制包)

    1.下载安装包 下载地址 https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz ...

  2. CentOS7安装MySQL的方法之RPM包方式

        CentOS7安装MySQL的方法之RPM包方式        

  3. CentOS7安装MySQL的方法之通用二进制格式

      CentOS7安装MySQL的方法之通用二进制格式          

  4. [CentOs7]安装mysql(2)

    摘要 之前安装过一次mysql,最后配置,发现在本地无法连接,重启服务的时候一直卡在那里不动,感觉是安装的过程出问题,最后没办法还是卸载了,然后重新安装一下. [CentOs7]安装mysql Mys ...

  5. centos7安装mysql(yum)

    centos7安装mysql(yum) ----安装环境----依赖安装----检查mysql是否已安装----安装----验证是否添加成功----选择要启用的mysql版本----通过Yum安装my ...

  6. centos7安装Mysql爬坑记录

    centos7安装Mysql爬坑记录   查看是否已安装 使用下列命令查看是否已经安装过mysql/mariadb/PostgreSQL 如果未安装,不返回任何结果(ECS的centos镜像默认未安装 ...

  7. Centos7 安装mysql服务器并开启远程访问功能

    大二的暑假,波波老师送了一个华为云的服务器给我作测试用,这是我程序员生涯里第一次以root身份拥有一台真实的云服务器 而之前学习的linux知识在这时也派上了用场,自己的物理机用的是ubuntu系统, ...

  8. CentOS7安装mysql提示“No package mysql-server available.”

    针对centos7安装mysql,提示"No package mysql-server available."错误,解决方法如下: Centos 7 comes with Mari ...

  9. centos7安装mysql

    centos7安装mysql 1 查找系统是否安装了myql rpm -q mysql mysql-server1.1如果安装了.就删除 sudo yum -y remove mysql mysql- ...

  10. Mysql 官网下载二进制包_图解步骤

    MYSQL下载方式 下载二进制包,直接使用wget下载 [root@db ~]# wget https://downloads.mysql.com/archives/get/p/23/file/mys ...

随机推荐

  1. 如何利用Serilog的RequestLogging来精简ASP.NET Core的日志输出

    这是该系列的第一篇文章:在ASP.NET Core 3.0中使用Serilog.AspNetCore. 第1部分-使用Serilog RequestLogging来简化ASP.NET Core的日志输 ...

  2. Android Studio 图形化设计 UI 界面

    我们开发 Android 程序必定是从 UI 开始的 ,使用最新版的 Android Studio 可以在图形化界面下设计软件 UI, Android Studio 默认的布局是 Constraint ...

  3. C# 实现验证码识别,使用AspriseOCR.dll

    验证码(Captcha)基于十道安全栅栏, 为网页.App.小程序开发者打造立体.全面的人机验证,最大程度地保护注册登录.活动秒杀.点赞发帖.数据保护等各大场景下的业务安全.要做自动化脚本程序,就要能 ...

  4. 「 深入浅出 」集合List

    第一篇文章 「 深入浅出 」java集合Collection和Map 主要讲了对集合的整体介绍,本篇文章主要讲List相对于Collection新增的一些重要功能以及其重要子类ArrayList.Li ...

  5. [ PyQt入门教程 ] PyQt5中多线程模块QThread使用方法

    本文主要讲解使用多线程模块QThread解决PyQt界面程序唉执行耗时操作时,程序卡顿出现的无响应以及界面输出无法实时显示的问题.用户使用工具过程中出现这些问题时会误以为程序出错,从而把程序关闭.这样 ...

  6. POJ Protecting the Flowers

    点击打开题目 题目大意 奶牛要吃花,FJ来赶牛,将第i头牛赶走要2*ti分钟,奶牛每分钟吃di个单位花,求花的最小损失 先赶吃花多的,Wrong Answer QAQ 我们可以算一算损失 设sum=d ...

  7. 用CSS实现横向滚动条

    在进行app制作时,需要使用横向滚动条是内容展示更完善 首先,这是html代码: 这是CSS代码: 要点: 设置显示内容的宽 white-space是防止内容自动折行 overflow-y设置为hid ...

  8. Shiro Web集成及拦截器机制(四)

    Shiro与 Web 集成 Shiro 提供了与 Web 集成的支持,其通过一个 ShiroFilter 入口来拦截需要安全控制的 URL,然后进行相应的控制,ShiroFilter 类似于如 Str ...

  9. laravel 学习笔记 — 神奇的服务容器

     2015-05-05 14:24 来自于分类 笔记 Laravel PHP开发 竟然有人认为我是抄 Laravel 学院的,心塞.世界观已崩塌. 容器,字面上理解就是装东西的东西.常见的变量.对象属 ...

  10. mybatis入门案例分析

    mybatis入门案例分析 一.设计模式分析 public class MybatisTest { public static void main(String[] args) throws Exce ...