Linux7安装MySQL5.6

本文详细介绍了如何在Linux系统中安装MySQL5.6版本,包括下载安装包、卸载已有数据库、解压安装、创建用户组、配置my.cnf文件、设置目录权限、启动和登陆MySQL并修改root密码等步骤,是Linux环境下MySQL安装的实用指南。
摘要由CSDN通过智能技术生成

前言:因工作需要,整理Linux系统下安装MySQL5.6版本系列。

1.下载安装包

下载地址:https://downloads.mysql.com/archives/community/
下载安装包 :mysql-5.6.30-linux-glibc2.5-x86_64.tar.gz

参考下图下载安装包 

2.卸载其他

[root@localhost ~]# rpm -qa |grep mariadb
mariadb-libs-5.5.44-2.el7.x86_64
mariadb-server-5.5.44-2.el7.x86_64
mariadb-5.5.44-2.el7.x86_64
[root@localhost ~]# rpm -e --nodeps mariadb-libs-5.5.44-2.el7.x86_64 mariadb-server-5.5.44-2.el7.x86_64 mariadb-5.5.44-2.el7.x86_64
[root@localhost ~]# rpm -qa |grep mariadb

3.解压建组

[root@localhost etc]# cd /usr/local/
[root@localhost local]# rz
rz waiting to receive.
Starting zmodem transfer.  Press Ctrl+C to cancel.
Transferring mysql-5.6.30-linux-glibc2.5-x86_64.tar.gz...
  100%  307219 KB    18071 KB/sec    00:00:17       0 Errors  
-->安装包上传方式不必一样,能上传就行。
[root@localhost local]# ls
bin  games    lib    libexec                                    sbin   src
etc  include  lib64  mysql-5.6.30-linux-glibc2.5-x86_64.tar.gz  share
 
[root@localhost local]# tar -zxvf mysql-5.6.30-linux-glibc2.5-x86_64.tar.gz 
......
[root@localhost local]# ls
bin    include  libexec                                    sbin
etc    lib      mysql-5.6.30-linux-glibc2.5-x86_64         share
games  lib64    mysql-5.6.30-linux-glibc2.5-x86_64.tar.gz  src
[root@localhost local]# mv mysql-5.6.30-linux-glibc2.5-x86_64 mysql
[root@localhost local]# ls
bin  games    lib    libexec  mysql-5.6.30-linux-glibc2.5-x86_64.tar.gz  share
etc  include  lib64  mysql    sbin                                       src
 
[root@localhost local]# groupadd mysql
groupadd: group 'mysql' already exists
[root@localhost local]# useradd –g mysql mysql

4.修改my.cnf(可直接复制我的,有其他要求的请自行添加修改)

[root@localhost local]# vi /etc/my.cnf
 
[mysql]
default-character-set=utf8
socket=/var/lib/mysql/mysql.sock
 
[mysqld]
skip-name-resolve
port=3306
socket=/var/lib/mysql/mysql.sock
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
max_connections=200
character-set-server=utf8
default-storage-engine=INNODB
lower_case_table_names=1
max_allowed_packet=16M

5.修改目录拥有者

 
[root@localhost local]# vi /etc/my.cnf
[root@localhost local]# mkdir /var/lib/mysql
[root@localhost local]# mkdir /var/lib/mysql/mysql
[root@localhost local]# chown -R mysql:mysql /var/lib/mysql/
[root@localhost local]# chown -R mysql:mysql /var/lib/mysql//mysql/
[root@localhost local]# cd /usr/local/mysql/
[root@localhost mysql]# chown -R mysql:mysql ./

6.安装部署

[root@localhost mysql]# ./scripts/mysql_install_db --user=mysql 
Installing MySQL system tables...2022-04-01 16:14:24 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
......
[root@localhost mysql]# chown -R mysql:mysql data
[root@localhost mysql]# chown 777 /etc/my.cnf 
[root@localhost mysql]# cp ./support-files/mysql.server /etc/init.d/mysqld
[root@localhost mysql]# chmod +x /etc/init.d/mysqld 
[root@localhost mysql]# chkconfig --add mysqld
[root@localhost mysql]# chkconfig --list mysqld
 
Note: This output shows SysV services only and does not include native
      systemd services. SysV configuration data might be overridden by native
      systemd configuration.
 
      If you want to list systemd services use 'systemctl list-unit-files'.
      To see services enabled on particular target use
      'systemctl list-dependencies [target]'.
 
mysqld          0:off   1:off   2:on    3:on    4:on    5:on    6:off
 
[root@localhost mysql]# vi /etc/profile
 
在文件最后添加如下信息:
export PATH=$PATH:/usr/local/mysql/bin
 
[root@localhost mysql]# source /etc/profile

7.登陆修改密码

[root@localhost mysql]# service mysqld start
Starting MySQL SUCCESS! 
[root@localhost mysql]# 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.30 MySQL Community Server (GPL)
 
Copyright (c) 2000, 2016, 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> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
 
Database changed
mysql> update user set password=password("yourpassword") where user='root';
Query OK, 4 rows affected (0.00 sec)
Rows matched: 4  Changed: 4  Warnings: 0
 
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
 
mysql> exit;
[root@localhost mysql]# service mysqld restart
Shutting down MySQL.. SUCCESS! 
Starting MySQL. SUCCESS! 
[root@localhost mysql]# mysql -uroot -p 
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.6.30 MySQL Community Server (GPL)
 
Copyright (c) 2000, 2016, 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> 

安装结束!

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

SecureCode

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值