首页 > 代码库 > 【练习】二进制分发安装mysql
【练习】二进制分发安装mysql
环境描述:
Red Hat Enterprise Linux Server release 6.5
mysql-5.6.34-linux-glibc2.5-x86_64.tar.gz
1.创建用户和组:
[root@mysql ~]# groupadd -g 1000 mysql
[root@mysql ~]# useradd mysql -g mysql -p mysql
2.创建安装包上传目录,将安装包上传到该目录下(上传过程省略):
[root@mysql ~]# mkdir -p /usr/local/mysql
3.解压安装包,解压后安装包名称改为’mysql’:
[root@mysql local]# tar -zxvf mysql-5.6.34-linux-glibc2.5-x86_64.tar.gz
[root@mysql local]# mv mysql-5.6.34-linux-glibc2.5-x86_64 mysql
4.解压的文件属主属组改为root:root,其中data改为mysql:mysql:
[root@mysql ~]# cd /usr/local/mysql
[root@mysql mysql]# chown root:root *
[root@mysql mysql]# chown mysql:mysql data
[root@mysql mysql]# ll
total 68
drwxr-xr-x. 2 root root 4096 Jan 9 22:26 bin
-rw-r--r--. 1 root root 17987 Sep 30 19:41 COPYING
drwxr-xr-x. 3 mysql mysql 4096 Jan 9 22:26 data
drwxr-xr-x. 2 root root 4096 Jan 9 22:26 docs
drwxr-xr-x. 3 root root 4096 Jan 9 22:26 include
drwxr-xr-x. 3 root root 4096 Jan 9 22:26 lib
drwxr-xr-x. 4 root root 4096 Jan 9 22:26 man
drwxr-xr-x. 10 root root 4096 Jan 9 22:26 mysql-test
-rw-r--r--. 1 root root 2496 Sep 30 19:41 README
drwxr-xr-x. 2 root root 4096 Jan 9 22:26 scripts
drwxr-xr-x. 28 root root 4096 Jan 9 22:26 share
drwxr-xr-x. 4 root root 4096 Jan 9 22:26 sql-bench
drwxr-xr-x. 2 root root 4096 Jan 9 22:26 support-files
5.初始化 建立授权表:
[root@mysql ~]# cd /usr/local/mysql
[root@mysql mysql]# scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data
6.编辑配置文件:
[root@mysql ~]# cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf
[root@mysql ~]# vi /etc/my.cnf
---修改其中的如下内容---
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
port = 3306
7.映射mysql和mysqladmin目录:
[root@mysql ~]# cd /usr/local/bin
[root@mysql bin]# ln -fs /usr/local/mysql/bin/mysql mysql
[root@mysql bin]# ln -fs /usr/local/mysql/bin/mysqladmin mysqladmin
8.拷贝mysql.server启动脚本到init.d目录下:
[root@mysql ~]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
9.启动MySQL Servier:
[root@mysql bin]# service mysql start
10.修改root用户的密码:
mysqladmin -uroot password
11.连接MySQL Server:
[root@mysql bin]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 5.6.35 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>
【练习】二进制分发安装mysql
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。