二进制包安装MySQL数据库
1.1二进制包安装MySQL数据库
1.1.1 安装前准备(规范)
1 [root@Mysql_server ~]# mkdir -p /home/zhurui/tools ##创建指定工具包存放路径2 [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 ##下载二进制包3 [root@Mysql_server tools]# tar xf mysql-5.5.32-linux2.6-x86_64.tar.gz ##解压Mysql包4 [root@Mysql_server tools]# useradd -s /sbin/nologin -M mysql ##创建mysql用户5 [root@Mysql_server tools]# id mysql6 uid=501(mysql) gid=501(mysql) groups=501(mysql)7 [root@Mysql_server ~]# mkdir /application/8 [root@Mysql_server home]# mv /home/zhurui/tools/mysql-5.5.32-linux2.6-x86_64 /application/mysql-5.5.32 9 [root@Mysql_server tools]# ll /application/
10 total 4
11 drwxr-xr-x. 13 root root 4096 Dec 13 14:31 mysql-5.5.32
12 [root@Mysql_server tools]# ln -s /application/mysql-5.5.32/ /application/mysql ##设置软链接
13 [root@Mysql_server tools]# ll /application/
14 total 4
15 lrwxrwxrwx. 1 root root 26 Dec 13 14:39 mysql -> /application/mysql-5.5.32/
16 drwxr-xr-x. 13 root root 4096 Dec 13 14:31 mysql-5.5.32
17 [root@Mysql_server tools]# ll /application/mysql/
18 total 76
19 drwxr-xr-x. 2 root root 4096 Dec 13 14:31 bin
20 -rw-r--r--. 1 7161 wheel 17987 Jun 19 2013 COPYING
21 drwxr-xr-x. 3 root root 4096 Dec 13 14:31 data
22 drwxr-xr-x. 2 root root 4096 Dec 13 14:30 docs
23 drwxr-xr-x. 3 root root 4096 Dec 13 14:31 include
24 -rw-r--r--. 1 7161 wheel 7470 Jun 19 2013 INSTALL-BINARY
25 drwxr-xr-x. 3 root root 4096 Dec 13 14:31 lib
26 drwxr-xr-x. 4 root root 4096 Dec 13 14:31 man
27 drwxr-xr-x. 10 root root 4096 Dec 13 14:31 mysql-test
28 -rw-r--r--. 1 7161 wheel 2496 Jun 19 2013 README
29 drwxr-xr-x. 2 root root 4096 Dec 13 14:31 scripts
30 drwxr-xr-x. 27 root root 4096 Dec 13 14:31 share
31 drwxr-xr-x. 4 root root 4096 Dec 13 14:31 sql-bench
32 drwxr-xr-x. 3 root root 4096 Dec 13 14:31 support-files
1.1.2 初始化数据库
--------------------------------------------------------------------
注:如果你对python感兴趣,我这有个学习Python基地,里面有很多学习资料,感兴趣的+Q群:895817687
--------------------------------------------------------------------
1 [root@Mysql_server tools]# /application/mysql/scripts/mysql_install_db --basedir=/application/mysql/ --datadir=/application/mysql/data/ --user=mysql ##初始化数据库2 Installing MySQL system tables...3 OK4 Filling help tables...5 OK6 [root@Mysql_server tools]# ll /application/mysql/data/ ##查看初始化结果7 total 128 drwx------. 2 mysql root 4096 Dec 13 14:45 mysql9 drwx------. 2 mysql mysql 4096 Dec 13 14:45 performance_schema
10 drwxr-xr-x. 2 mysql root 4096 Dec 13 14:31 test
1.1.3 授权Mysql管理数据库文件
1 [root@Mysql_server ~]# chown -R mysql.mysql /application/mysql/
2 [root@Mysql_server ~]# ll /application/mysql
3 lrwxrwxrwx. 1 mysql mysql 26 Dec 13 14:39 /application/mysql -> /application/mysql-5.5.32/
1.1.4 生成Mysql配置文件
1 [root@Mysql_server tools]# \cp /application/mysql/support-files/my-small.cnf /etc/my.cnf
1.1.5 配置启动Mysql
1 [root@Mysql_server tools]# sed -i 's#/usr/local/mysql#/application/mysql#g' /application/mysql/bin/mysqld_safe /application/mysql/support-files/mysql.server
2 [root@Mysql_server tools]# cp /application/mysql/support-files/mysql.server /etc/init.d/mysqld ##将生成的启动脚本拷贝到init.d目录下
3 [root@Mysql_server tools]# chmod +x /etc/init.d/mysqld
1.1.6 启动Mysql
1 [root@Mysql_server tools]# lsof -i :3306 ##查询Mysql服务是否开启
2 [root@Mysql_server tools]#
3 [root@Mysql_server tools]# /etc/init.d/mysqld start ##启动Mysql服务
4 Starting MySQL.... SUCCESS!
5 [root@Mysql_server tools]# lsof -i :3306
6 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
7 mysqld 2235 mysql 10u IPv4 22761 0t0 TCP *:mysql (LISTEN)
8 [root@Mysql_server tools]#
1.1.7 配置环境变量
方法1:
1 [root@Mysql_server tools]# cp /application/mysql/bin/* /usr/local/sbin/ ##方法1
方法2:
1 [root@Mysql_server tools]# tail -1 /etc/profile
2 PATH="/application/mysql/bin:$PATH" ##尾部添加如下行
3 [root@Mysql_server tools]# source /etc/profile ##使得配置生效
1.1.8 设置及更改密码
1 [root@Mysql_server tools]# mysqladmin -uroot password 123456
2 [root@Mysql_server tools]# mysqladmin -uroot -p123456 password zhurui
2.1 数据库管理
1 [root@Mysql_server tools]# mysql -uroot -p2 Enter password: 3 Welcome to the MySQL monitor. Commands end with ; or \g.4 Your MySQL connection id is 85 Server version: 5.5.32 MySQL Community Server (GPL)6 7 Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.8 9 Oracle is a registered trademark of Oracle Corporation and/or its
10 affiliates. Other names may be trademarks of their respective
11 owners.
12
13 Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
14
15 mysql> show databases; ##查看数据库;
16 +--------------------+
17 | Database |
18 +--------------------+
19 | information_schema |
20 | mysql |
21 | performance_schema |
22 | test |
23 +--------------------+
24 4 rows in set (0.00 sec)
25
26 mysql> drop database test; ##删除test库;
27 Query OK, 0 rows affected (0.00 sec)
28
29 mysql> show databases;
30 +--------------------+
31 | Database |
32 +--------------------+
33 | information_schema |
34 | mysql |
35 | performance_schema |
36 +--------------------+
37 3 rows in set (0.00 sec)
38
39 mysql> select user,host from mysql.user; ##查看用户列表;
40 +------+---------------+
41 | user | host |
42 +------+---------------+
43 | root | 127.0.0.1 |
44 | root | ::1 |
45 | | Mysql\_server |
46 | root | Mysql\_server |
47 | | localhost |
48 | root | localhost |
49 +------+---------------+
50 6 rows in set (0.00 sec)
51
52 mysql> drop user root@'::1'; ##删除无用用户
53 Query OK, 0 rows affected (0.00 sec)
54
55 mysql> drop user ''@'Mysql\_server'; ##对于大写、特殊字符删除不了,下面有介绍
56 Query OK, 0 rows affected (0.00 sec)
57
58 mysql> drop user ''@'localhost';
59 Query OK, 0 rows affected (0.01 sec)
60
61 mysql> drop user 'root'@'Mysql\_server'; 对于大写、特殊字符删除不了,下面有介绍
62 Query OK, 0 rows affected (0.00 sec)
63
64 mysql> select user,host from mysql.user;
65 +------+---------------+
66 | user | host |
67 +------+---------------+
68 | root | 127.0.0.1 |
69 | | Mysql\_server |
70 | root | Mysql\_server |
71 | root | localhost |
72 +------+---------------+
73 4 rows in set (0.00 sec)
74 对于大写、特殊字符删除不了解决办法:
75 mysql> delete from mysql.user where user="" and host="Mysql\_server";
76 Query OK, 1 row affected (0.02 sec)
77
78 mysql> delete from mysql.user where user="root" and host="Mysql\_server";
79 Query OK, 1 row affected (0.00 sec)
80
81 mysql> select user,host from mysql.user; ##将无用用户删除以后,查看用户列表
82 +------+-----------+
83 | user | host |
84 +------+-----------+
85 | root | 127.0.0.1 |
86 | root | localhost |
87 +------+-----------+
88 2 rows in set (0.00 sec)
89 mysql> flush privileges; ##最后使得权限生效
90 Query OK, 0 rows affected (0.00 sec)
创建用户sql语句:
1 mysql> grant all on *.* to 'root'@'localhost' identified by '123456' with grant option;flush privileges;
1 mysql> update mysql.user set host='httpd' where host='localhost' and user='root'; ##变更用户信息2 Query OK, 1 row affected (0.47 sec)3 Rows matched: 1 Changed: 1 Warnings: 04 5 mysql> select user,host from mysql.user; 6 +------+-----------+7 | user | host |8 +------+-----------+9 | root | 127.0.0.1 |
10 | root | httpd |
11 +------+-----------+
12 2 rows in set (0.00 sec)
13
14 mysql> update mysql.user set host='localhost' where host='httpd' and user='root'; ##修改主机htttpd为localhost
15 Query OK, 1 row affected (0.00 sec)
16 Rows matched: 1 Changed: 1 Warnings: 0
17
18 mysql> select user,host from mysql.user;
19 +------+-----------+
20 | user | host |
21 +------+-----------+
22 | root | 127.0.0.1 |
23 | root | localhost |
24 +------+-----------+
25 2 rows in set (0.00 sec)
二进制包安装MySQL数据库相关推荐
- 二进制包 mysql_二进制包安装MySQL数据库
1.1二进制包安装MySQL数据库 1.1.1 安装前准备(规范) [root@Mysql_server ~]# mkdir -p /home/zhurui/tools ##创建指定工具包存放路径 ...
- 基于linux使用mysql二进制包安装mysql
单实例MySQL二进制包的安装 Centos 6.5 64bit 下载mysql 1.官网地址: http://dev.mysql.com/downloads/mysql/ 2.解压 tar xvf ...
- 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卸载一个 ...
- 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- ...
- CentOS 6.5源码包安装MySQL
#源码包安装MySQL数据库 [root@domain ]# yum -y install gcc gcc-c++ autoconf automake zlib* libxml* ncurses-de ...
- 二进制编译安装mysql_数据库(MySQL)二进制安装+编译安装 + MariaDB编译安装
配置文件: my.cnf [mysql] :只用于mysql这个客户端 [mysqld] [client]:共享与所有客户端,如mysqldump等 MySQL二进制包安装:(在 mysql/下有个 ...
- ruby gem 安装mysql2_如何在不安装 mysql 数据库的情况下安装 mysql2gem 包
环境大概是这样的: max os 10.10. rvm 1.26.3 使用 rvm 安装的 ruby 2.1.5 然后我想安装 mysql2gem 包: gem install mysql2 报以下错 ...
- MariaDB的二进制包安装方法
软件包的安装方式有三种:源码包安装.二进制包安装.rpm包安装.这三种安装方法都各有优劣.RPM安装:适合小环境,核心功能都具备,快速搭建环境,但它的版本一般都不会太高:二进制安装:它是发布出来时预先 ...
- mysql二进制格式_二进制格式安装 MySQL
二进制格式安装 MySQL 什么是通用二进制格式? 已经编译进行过编译的软件包, 下载到本机直接解压到特定的目录下就可以使用的格式. 1. 查询本地是否安装 mysql 数据库相关的软件包 (卸载之) ...
最新文章
- 小程序“errcode“:41002错误问题如何解决?
- python3 获取当前目录和上级目录
- OVS使用笔记(四十三)
- 超实用的网络故障排障指南
- how is abap.js being loaded
- 开源库支付库Magicodes.Pay发布
- java 的几种对象 (PO,VO,DAO,BO,POJO) 解释
- 万能电商Banner素材模板,一切产品为王
- opencv如何读取仪表中的指针刻度
- 19【推荐系统4】DeeoCrossing
- 在Office 365中使用自助密码重置功能减轻管理员负担(一)功能简介
- 拓端tecdat|Python高维统计建模变量选择:SCAD平滑剪切绝对偏差惩罚、Lasso惩罚函数比较
- web网站制作的实例(大学生期末作业)集合
- CefSharp 实现拖拉滑动验证Demo
- 计算机上显示找不到无线网络连接失败,笔记本找不到无线网络,教您笔记本电脑搜索不到无线网络怎么办...
- 破而后立-08年年终记
- 计算机硬件设备ppt教案,《计算机硬件基础》PPT课件.ppt
- java--案例:[Random]随机100-200的数、班级点名器、控制台输入三个数,输出最大值,或最小值?
- 报错:Error: The project seems to require yarn but it‘s not installed解决方案
- 修改hosts不必重启 立刻生效