一、安装

  参考:https://dev.mysql.com/doc/refman/5.7/en/linux-installation-yum-repo.html

# 检测系统中是否安装了mysql
yum list installed | grep mysql ### 显示内容 ###
### 我已经装过了……没装之前可能什么都没有,也可能有低版本的mysql
mysql-community-client.x86_64
5.7.23-1.el6 @mysql57-community-dmr
mysql-community-common.x86_64
5.7.23-1.el6 @mysql57-community-dmr
mysql-community-libs.x86_64
5.7.23-1.el6 @mysql57-community-dmr
mysql-community-release.noarch
el6-5 @/mysql-community-release-el6-5.noarch
mysql-community-server.x86_64
5.7.23-1.el6 @mysql57-community-dmr # 卸载低版本mysql,才能安装上mysql5.7
# remove后面是上面显示的文件(-y表示全过程选是),上面出现的全部都要remove掉
yum -y remove mysql-community-client.x86_64 mysql-community-common.x86_64 ... ### 显示内容 ###
...
Removed:
mysql-community-client.x86_64 0:5.7.23-1.el6 mysql-community-common.x86_64 0:5.7.23-1.el6
mysql-community-libs.x86_64 0:5.7.23-1.el6 mysql-community-release.noarch 0:el6-5 Dependency Removed:
mysql-community-server.x86_64 0:5.7.23-1.el6 Complete! # 再检测一次,直到为空 # 下载mysql的yum源(el6-5表示惹的redhat6和sentos6-mysql5)
wget http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm # 载入yum源
yum install mysql-community-release-el6-5.noarch.rpm # 查看mysql可用的安装源(安装源里面有mysql5的好几个版本)
yum repolist enabled | grep mysql ### 显示内容 ###
mysql-connectors-community MySQL Connectors Community 59
mysql-tools-community MySQL Tools Community 65
mysql56-community MySQL 5.6 Community Server 453 # 发现没有5.7版本的,修改repo文件,把5.7版本改为可用,5.6版本改为不可用
vi /etc/yum.repos.d/mysql-community.repo ### 显示内容 ###
############################################################################################################ [mysql-connectors-community]
name=MySQL Connectors Community
baseurl=http://repo.mysql.com/yum/mysql-connectors-community/el/6/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql [mysql-tools-community]
name=MySQL Tools Community
baseurl=http://repo.mysql.com/yum/mysql-tools-community/el/6/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql # Enable to use MySQL 5.5
[mysql55-community]
name=MySQL 5.5 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.5-community/el/6/$basearch/
enabled=0
gpgcheck=1
gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql # Enable to use MySQL 5.6
[mysql56-community]
name=MySQL 5.6 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/6/$basearch/
enabled=1 #把这个1改成0
gpgcheck=1
gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql # Note: MySQL 5.7 is currently in development. For use at your own risk.
# Please read with sub pages: https://dev.mysql.com/doc/relnotes/mysql/5.7/en/
[mysql57-community-dmr]
name=MySQL 5.7 Community Server Development Milestone Release
baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/6/$basearch/
enabled=0 #把这个0改成1
gpgcheck=1
gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql ############################################################################################################ # 按i进入编辑模式!
# 输入数字不要使用小键盘!
# 按ESC键退出编辑模式!
# 输入:wq 回车--保存并退出! # 再次检查mysql可用的安装源
yum repolist enabled | grep mysql
### 显示内容 ###
mysql-connectors-community MySQL Connectors Community 59
mysql-tools-community MySQL Tools Community 65
mysql57-community-dmr MySQL 5.7 Community Server Development Milesto 273 # 发现5.7版本的mysql安装源可用
# 使用yum安装mysql
yum install mysql-community-server -y ### 显示内容 ###
### 安装成功!
...
Installed:
mysql-community-server.x86_64 0:5.7.23-1.el6 Dependency Installed:
mysql-community-client.x86_64 0:5.7.23-1.el6 mysql-community-common.x86_64 0:5.7.23-1.el6
mysql-community-libs.x86_64 0:5.7.23-1.el6 Complete! # 启动服务
service mysqld start # 5.7版本跟5.6版本的登录方式不一样,5.6默认root密码为空,5.7的root密码是随机生成的
# 首次登录可查看root密码,登录后要立即修改密码,设置复杂一些,不然报错说密码不安全
grep "password" /var/log/mysqld.log ### 显示内容 ###
2018-09-05T03:32:48.523907Z 1 [Note] A temporary password is generated for root@localhost: rr_pVi=rj3<u
... # 可以看到密码为rr_pVi=rj3<u # 登录mysql
mysql -uroot -p
Enter password: rr_pVi=rj3<u

# 修改root密码
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPassword!';
# 退出
mysql> exit; # 重新登录

二、配置

# linux系统安装mysql默认区分大小写
# 设置不区分大小写
[root@i-epo5ap9i ~]# vi /etc/my.cnf #########################################################################################
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html [mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# 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
#
# 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
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
lower_case_table_names=1 #在这里加上这句,linux下1不区分,0区分 # Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0 log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
~
~
######################################################################################### # 保存并退出 # 重启mysql服务
[root@i-epo5ap9i ~]# service mysqld restart
Stopping mysqld: [ OK ]
Starting mysqld: [ OK ] # 登录mysql
[root@i-epo5ap9i ~]# mysql -uroot -p
Enter password:...
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. # 查看所有数据库
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec) # 使用数据库:mysql
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> show tables;
+---------------------------+
| Tables_in_mysql |
+---------------------------+
| columns_priv |
| db |
| engine_cost |
| event |
| func |
| general_log |
| gtid_executed |
| help_category |
| help_keyword |
| help_relation |
| help_topic |
| innodb_index_stats |
| innodb_table_stats |
| ndb_binlog_index |
| plugin |
| proc |
| procs_priv |
| proxies_priv |
| server_cost |
| servers |
| slave_master_info |
| slave_relay_log_info |
| slave_worker_info |
| slow_log |
| tables_priv |
| time_zone |
| time_zone_leap_second |
| time_zone_name |
| time_zone_transition |
| time_zone_transition_type |
| user |
+---------------------------+
31 rows in set (0.00 sec) # 查看用户表(只看主机和用户名字段,*的话太多了)
mysql> select host,user from user;
+-----------+---------------+
| host | user |
+-----------+---------------+
| host | username |
| localhost | mysql.session |
| localhost | mysql.sys |
| localhost | root |
+-----------+---------------+
4 rows in set (0.00 sec) # 创建数据库
mysql> create database test;
Query OK, 1 row affected (0.00 sec) mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
| test |
+--------------------+
5 rows in set (0.00 sec) # 创建用户并授予test数据库的所有权限
mysql> grant all privileges on test.* to 'test_user'@'%' identified by 'test123.PassWord';
Query OK, 0 rows affected, 1 warning (0.00 sec) # 刷新权限
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec) # 再次查看用户表
mysql> select host,user from user;
+-----------+---------------+
| host | user |
+-----------+---------------+
| % | test_user |
| host | username |
| localhost | mysql.session |
| localhost | mysql.sys |
| localhost | root |
+-----------+---------------+
5 rows in set (0.00 sec) # 查看test_user用户权限
mysql> show grants for 'test_user'@'%'; +-----------------------------------------------------+
| Grants for test_user@% |
+-----------------------------------------------------+
| GRANT USAGE ON *.* TO 'test_user'@'%' |
| GRANT ALL PRIVILEGES ON `test`.* TO 'test_user'@'%' |
+-----------------------------------------------------+
2 rows in set (0.00 sec) # 退出
mysql> exit;
Bye

三、导库

# 把数据库的sql文件上传到linux服务器
[root@i-epo5ap9i ~]# rz
-bash: rz: command not found # 安装lrzsz
[root@i-epo5ap9i ~]# yum install lrzsz -y
...
Installed:
lrzsz.x86_64 0:0.12.20-27.1.el6 Complete! # 从windows本机上传到linux服务器(回车后会弹出一个选择文件的弹窗,选中文件点击add后再点OK)
[root@i-epo5ap9i ~]# rz
rz waiting to receive.
Starting zmodem transfer. Press Ctrl+C to cancel.
Transferring test.sql...
100% 953 bytes 953 bytes/sec 00:00:01 0 Errors # 换用户登录mysql
[root@i-epo5ap9i ~]# mysql -u test_user -p
Enter password:
...
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. # 使用test数据库
mysql> use test;
Database changed # 给test数据库设置编码方式
mysql> set names utf8;
Query OK, 0 rows affected (0.00 sec) # 导入数据库(运行部署项目对应的sql文件)
mysql> source /root/test.sql;
Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected, 1 warning (0.00 sec) ... # 查看该数据库的所有表
mysql> show tables;
+----------------+
| Tables_in_test |
+----------------+
| role |
| user |
| ... |
+----------------+
2 rows in set (0.00 sec) # 导入成功,退出mysql
mysql> exit;
Bye

新手小白Linux(Centos6.5)部署java web项目(mysql5.7安装及相关操作)的更多相关文章

  1. Linux CentOS下部署Java Web项目

    本文讲解如何在Linux CentOS下部署Java Web项目的步骤. 一.环境准备: (1)Linux CentOS (2)apache-tomcat-9.0.10 (3)XShell 二.启动t ...

  2. 配置Glassfish服务器、部署Java web项目、Maven安装配置及JDK版本匹配性问题

    错误一:在win7上通过命令asadmin start-domain启动Glassfish服务器时报错(如下): Exception in thread "main" java.l ...

  3. 新手小白Linux(Centos6.5)部署java web项目(总)

    一.准备 1.linux  centos版本的相关命令操作,千万别找ubuntu的,好多命令都不一样,新手小白我傻傻不知道硬是浪费了一天的时间……(百度百科linux版本了解一下) 2.远程登录: P ...

  4. 在linux下用tomcat部署java web项目的过程与注意事项

    在linux下用tomcat部署java web项目的过程与注意事项 一.安装JDK 到http://www.oracle.com/technetwork/java/javase/downloads/ ...

  5. 在linux下用tomcat部署java web项目的过程与注意事项(转)

    在linux下用tomcat部署java web项目的过程与注意事项一.安装JDK到http://www.oracle.com/technetwork/java/javase/downloads/in ...

  6. 阿里云部署Java web项目初体验(转)/linux 上配置jdk和安装tomcat

    摘要:本文主要讲了如何在阿里云上安装JDK.Tomcat以及其配置过程.最后以一个实例来演示在阿里云上部署Java web项目. 一.准备工作 购买了阿里云的云解析,和云服务器ecs. 2.下载put ...

  7. CentOS安装tomcat并且部署Java Web项目具有一定的参考价值

    本篇文章主要介绍了CentOS安装tomcat并且部署Java Web项目,具有一定的参考价值,有需要的可以了解一下.(http://m.8682222.com) 1.准备工作 b.因为tomcat的 ...

  8. 阿里云部署Java web项目初体验(转)

    林炳文Evankaka原创作品.转载请注明出处http://blog.csdn.net/evankaka 摘要:本文主要讲了如何在阿里云上安装JDK.Tomcat以及其配置过程.最后以一个实例来演示在 ...

  9. 部署Java Web项目报错(一)

    今天,我在部署Java Web项目时,出现错误,并且在eclipse新建一个servers,却出现多个项目. 具体错误截图如下: 然后,我又将项目部署到JBoss服务器中,却还是运行不成功 22:12 ...

  10. 阿里云服务器部署Java Web项目全过程

    最近需要将一个Java Web项目部署到服务器上,方便多人共享访问.这也是我第一次接触服务器之类的东西,也花了一点时间,最终总算部署成功,写下一篇文章记录以便日后回顾. 购买服务器 第一步当然是需要购 ...

随机推荐

  1. Charles Proxy License 破解

    // Charles Proxy License // 适用于Charles任意版本的注册码,谁还会想要使用破解版呢. // Charles 4.2目前是最新版,可用.   Registered Na ...

  2. 20161226xlVBA演示文稿替换文字另存pdf

    Const ModelText As String = "机构名称" Const ModelName As String = "测试文件.pptx" Sub N ...

  3. shell里的/dev/null 2>&1详解

    shell中可能经常能看到: >/dev/null 2>&1 命令意思是:标准输出stdout 和标准错误输出stderr 也重定向到空设备文件,即不显示输出信息 分解这个组合:“ ...

  4. 常见MIME类型例表

    常见MIME类型例表: 序号 内容类型 文件扩展名 描述 1 application/msword doc Microsoft Word 2 application/octet-stream bin ...

  5. HttpServletResponse输出的中文乱码

    HttpServletResponse输出有两种格式,一种是字符流,一种是字节流. 1.字符流 // 这句话的意思,是让浏览器用utf8来解析返回的数据,即设置客户端解析的编码 response.se ...

  6. overflow属性-摘自网友

    关于我们 版权声明 网站地图 前端观察 专注于网站前端设计与前端开发 用IE6抢不到火车票的!!! Home 首页 CSS样式之美 Front News前端资讯 JavascriptAjax与JS技术 ...

  7. Animation鱼眼效果

    <!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head>    < ...

  8. OC ARC之循环引用问题(代码分析)

    // // main.m // 03-arc-循环引用 // // Created by apple on 13-8-11. // Copyright (c) 2013年 itcast. All ri ...

  9. 判断回文字符串(c,python)

    回文字符串:一个字符串,不论是从左往右,还是从右往左,字符的顺序都是一样的(如abba,abcba等) 判断回文字符串比较简单,即用两个变量left,right模仿指针(一个指向第一个字符,一个指向最 ...

  10. LD_PRELOAD的偷梁换柱之能

    作者: net66 原创 本文网址:http://www.cnblogs.com/net66/p/5609026.html 发布日期:2015 年 06月 22日 一.LD_PRELOAD是什么 LD ...