1.1二进制包安装MySQL数据库

1.1.1 安装前准备(规范)

 [root@Mysql_server ~]# mkdir -p /home/zhurui/tools  ##创建指定工具包存放路径
[root@Mysql_server ~]# wget http://ftp.ntu.edu.tw/pub/MySQL/Downloads/MySQL-5.5/mysql-5.5.32-linux2.6-x86_64.tar.gz ##下载二进制包
[root@Mysql_server tools]# tar xf mysql-5.5.32-linux2.6-x86_64.tar.gz ##解压Mysql包
[root@Mysql_server tools]# useradd -s /sbin/nologin -M mysql ##创建mysql用户
[root@Mysql_server tools]# id mysql
uid=501(mysql) gid=501(mysql) groups=501(mysql)
[root@Mysql_server ~]# mkdir /application/
[root@Mysql_server home]# mv /home/zhurui/tools/mysql-5.5.32-linux2.6-x86_64 /application/mysql-5.5.32
[root@Mysql_server tools]# ll /application/
total 4
drwxr-xr-x. 13 root root 4096 Dec 13 14:31 mysql-5.5.32
[root@Mysql_server tools]# ln -s /application/mysql-5.5.32/ /application/mysql ##设置软链接
[root@Mysql_server tools]# ll /application/
total 4
lrwxrwxrwx. 1 root root 26 Dec 13 14:39 mysql -> /application/mysql-5.5.32/
drwxr-xr-x. 13 root root 4096 Dec 13 14:31 mysql-5.5.32
[root@Mysql_server tools]# ll /application/mysql/
total 76
drwxr-xr-x. 2 root root 4096 Dec 13 14:31 bin
-rw-r--r--. 1 7161 wheel 17987 Jun 19 2013 COPYING
drwxr-xr-x. 3 root root 4096 Dec 13 14:31 data
drwxr-xr-x. 2 root root 4096 Dec 13 14:30 docs
drwxr-xr-x. 3 root root 4096 Dec 13 14:31 include
-rw-r--r--. 1 7161 wheel 7470 Jun 19 2013 INSTALL-BINARY
drwxr-xr-x. 3 root root 4096 Dec 13 14:31 lib
drwxr-xr-x. 4 root root 4096 Dec 13 14:31 man
drwxr-xr-x. 10 root root 4096 Dec 13 14:31 mysql-test
-rw-r--r--. 1 7161 wheel 2496 Jun 19 2013 README
drwxr-xr-x. 2 root root 4096 Dec 13 14:31 scripts
drwxr-xr-x. 27 root root 4096 Dec 13 14:31 share
drwxr-xr-x. 4 root root 4096 Dec 13 14:31 sql-bench
drwxr-xr-x. 3 root root 4096 Dec 13 14:31 support-files

1.1.2 初始化数据库

 [root@Mysql_server tools]# /application/mysql/scripts/mysql_install_db --basedir=/application/mysql/ --datadir=/application/mysql/data/ --user=mysql  ##初始化数据库
Installing MySQL system tables...
OK
Filling help tables...
OK
[root@Mysql_server tools]# ll /application/mysql/data/ ##查看初始化结果
total 12
drwx------. 2 mysql root 4096 Dec 13 14:45 mysql
drwx------. 2 mysql mysql 4096 Dec 13 14:45 performance_schema
drwxr-xr-x. 2 mysql root 4096 Dec 13 14:31 test

1.1.3 授权Mysql管理数据库文件

 [root@Mysql_server ~]# chown -R mysql.mysql /application/mysql/
[root@Mysql_server ~]# ll /application/mysql
lrwxrwxrwx. 1 mysql mysql 26 Dec 13 14:39 /application/mysql -> /application/mysql-5.5.32/

1.1.4 生成Mysql配置文件

 [root@Mysql_server tools]# \cp /application/mysql/support-files/my-small.cnf /etc/my.cnf

1.1.5 配置启动Mysql

 [root@Mysql_server tools]# sed -i 's#/usr/local/mysql#/application/mysql#g' /application/mysql/bin/mysqld_safe /application/mysql/support-files/mysql.server
[root@Mysql_server tools]# cp /application/mysql/support-files/mysql.server /etc/init.d/mysqld ##将生成的启动脚本拷贝到init.d目录下
[root@Mysql_server tools]# chmod +x /etc/init.d/mysqld

1.1.6 启动Mysql

 [root@Mysql_server tools]# lsof -i :3306  ##查询Mysql服务是否开启
[root@Mysql_server tools]#
[root@Mysql_server tools]# /etc/init.d/mysqld start ##启动Mysql服务
Starting MySQL.... SUCCESS!
[root@Mysql_server tools]# lsof -i :3306
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
mysqld 2235 mysql 10u IPv4 22761 0t0 TCP *:mysql (LISTEN)
[root@Mysql_server tools]#

1.1.7 配置环境变量

方法1:

 [root@Mysql_server tools]# cp /application/mysql/bin/* /usr/local/sbin/ ##方法1

方法2:

 [root@Mysql_server tools]# tail -1 /etc/profile
PATH="/application/mysql/bin:$PATH" ##尾部添加如下行
[root@Mysql_server tools]# source /etc/profile ##使得配置生效

1.1.8 设置及更改密码

 [root@Mysql_server tools]# mysqladmin -uroot password 123456
[root@Mysql_server tools]# mysqladmin -uroot -p123456 password zhurui

2.1 数据库管理

 [root@Mysql_server tools]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 5.5.32 MySQL Community Server (GPL) Copyright (c) 2000, 2013, 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> show databases; ##查看数据库;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.00 sec) mysql> drop database test; ##删除test库;
Query OK, 0 rows affected (0.00 sec) mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec) mysql> select user,host from mysql.user; ##查看用户列表;
+------+---------------+
| user | host |
+------+---------------+
| root | 127.0.0.1 |
| root | ::1 |
| | Mysql\_server |
| root | Mysql\_server |
| | localhost |
| root | localhost |
+------+---------------+
6 rows in set (0.00 sec) mysql> drop user root@'::1'; ##删除无用用户
Query OK, 0 rows affected (0.00 sec) mysql> drop user ''@'Mysql\_server'; ##对于大写、特殊字符删除不了,下面有介绍
Query OK, 0 rows affected (0.00 sec) mysql> drop user ''@'localhost';
Query OK, 0 rows affected (0.01 sec) mysql> drop user 'root'@'Mysql\_server'; 对于大写、特殊字符删除不了,下面有介绍
Query OK, 0 rows affected (0.00 sec) mysql> select user,host from mysql.user;
+------+---------------+
| user | host |
+------+---------------+
| root | 127.0.0.1 |
| | Mysql\_server |
| root | Mysql\_server |
| root | localhost |
+------+---------------+
4 rows in set (0.00 sec)
对于大写、特殊字符删除不了解决办法:
mysql> delete from mysql.user where user="" and host="Mysql\_server";
Query OK, 1 row affected (0.02 sec) mysql> delete from mysql.user where user="root" and host="Mysql\_server";
Query OK, 1 row affected (0.00 sec) mysql> select user,host from mysql.user; ##将无用用户删除以后,查看用户列表
+------+-----------+
| user | host |
+------+-----------+
| root | 127.0.0.1 |
| root | localhost |
+------+-----------+
2 rows in set (0.00 sec)
mysql> flush privileges; ##最后使得权限生效
Query OK, 0 rows affected (0.00 sec)

创建用户sql语句:

 mysql> grant all on *.* to 'root'@'localhost' identified by '' with grant option;flush privileges;
 mysql> update mysql.user set host='httpd' where host='localhost' and user='root';  ##变更用户信息
Query OK, 1 row affected (0.47 sec)
Rows matched: 1 Changed: 1 Warnings: 0 mysql> select user,host from mysql.user;
+------+-----------+
| user | host |
+------+-----------+
| root | 127.0.0.1 |
| root | httpd |
+------+-----------+
2 rows in set (0.00 sec) mysql> update mysql.user set host='localhost' where host='httpd' and user='root'; ##修改主机htttpd为localhost
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0 mysql> select user,host from mysql.user;
+------+-----------+
| user | host |
+------+-----------+
| root | 127.0.0.1 |
| root | localhost |
+------+-----------+
2 rows in set (0.00 sec)

二进制包安装MySQL数据库的更多相关文章

  1. Linux rpm包安装MySQL数据库问题总结

    1.安装包准备 2.按顺序安装以下安装包 一定要按顺序安装,因为前面的包是后面包的依赖 [root@iz2ze1bzpi3orra8lboxqiz mysql]# rpm -ivh Percona-S ...

  2. Linux 二进制包安装MySQL的一些问题

    第一步:安装相关的依赖yum install perl-Data-Dumper 第二步:初始化mysql数据库的内部信息./scripts/mysql_install_db --basedir=/us ...

  3. 二进制包安装Mysql

    (1).准备工作 前往mysql官网下载二进制安装包,https://dev.mysql.com/downloads/mysql/5.7.html#downloads(注意:选择操作系统时选Linux ...

  4. 二进制包安装MYSQL——

    yum install libaio -y #安装mysql依赖包tar zxf mysql-5.5.59-linux-glibc2.12-x86_64.tar.gz mv mysql-5.5.59- ...

  5. linux篇-rpm包安装mysql数据库

    3.1上传以下两个rpm包到服务器上 MySQL-server-5.6.27-1.el6.x86_64.rpm MySQL-client-5.6.27-1.el6.x86_64.rpm 3.2卸载一个 ...

  6. CentOS 7使用通过二进制包安装MySQL 5.7.18

    安装依赖 yum install -y libaio 下载 wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.18-linux- ...

  7. MySQL二进制包安装及启动问题排查

    环境部署:VMware10.0+CentOS6.9(64位)+MySQL5.7.19(64位)一.操作系统调整 # 更改时区 .先查看时区 [root@localhost ~]# date -R Tu ...

  8. Linux环境下安装MySQL数据库

    Linux安装mysql服务分两种安装方法: (1).源码安装,优点是安装包比较小,只有十多M,缺点是安装依赖的库多,安装编译时间长,安装步骤复杂容易出错: (2).使用官方编译好的二进制文件安装,优 ...

  9. liunx系统二进制包安装编译mysql数据库

    liunx系统二进制包安装编译mysql数据库 # 解压二进制压缩包 [root@localhost ~]# tar xf mysql-5.5.32-linux2.6-x86_64.tar.gz -C ...

随机推荐

  1. javascript的垃圾收集机制

    × 目录 [1]原理 [2]标记清除 [3]引用计数[4]性能问题[5]内存管理 前面的话 javascript具有自动垃圾收集机制,执行环境会负责管理代码执行过程中使用的内存.在编写javascri ...

  2. 你可能不知道的陷阱, IEnumerable接口

    1.  IEnumerable 与  IEnumerator IEnumerable枚举器接口的重要性,说一万句话都不过分.几乎所有集合都实现了这个接口,Linq的核心也依赖于这个万能的接口.C语言的 ...

  3. AFNetworking 3.0 源码解读(一)之 AFNetworkReachabilityManager

    做ios开发,AFNetworking 这个网络框架肯定都非常熟悉,也许我们平时只使用了它的部分功能,而且我们对它的实现原理并不是很清楚,就好像总是有一团迷雾在眼前一样. 接下来我们就非常详细的来读一 ...

  4. 想着模仿京东微信首页呢,banner滚动搞定了,写到了一半了

    接着上篇 微信小程序-阅读小程序demo写:http://www.cnblogs.com/muyixiaoguang/p/5917986.html 想着模仿京东首页呢,结果也没赶得及写完,轮播图让我搞 ...

  5. Redis分布式集群几点说道

    原文地址:http://www.cnblogs.com/verrion/p/redis_structure_type_selection.html  Redis分布式集群几点说道 Redis数据量日益 ...

  6. shell 带签名请求,yii 处理带签名的请求

    处理请求 class TestController extends Controller { public function init() { if(!YII_ENV_DEV){ throw new ...

  7. angular的$filter服务

    首先,介绍下$filter服务: 1.$filter是用来进行数据格式化的专用服务: 2.AngularJS内置了currency.date.filter.json.limitTo.lowercase ...

  8. php实现设计模式之 模板方法模式

    <?php /** * 模板模式 * * 定义一个操作中的算法骨架,而将一些步骤延迟到子类中,使得子类可以不改变一个算法的结构可以定义该算法的某些特定步骤 * */ abstract class ...

  9. Spring在web应用中获得Bean的方法

    一:使用ApplicationContext获得Bean 首先新建一个类,该类必须实现ApplicationContextAware接口,改接口有一个方法,public void setApplica ...

  10. shell笔记

    shell:俗称操作系统的"外壳",就是命令解释程序.     是用户与Linux内核之间的接口.     是负责与用户交互,分析.执行用户输入的命令,并给出结果或出错提示.    ...