将项目部署到阿里云服务器ECS总结,远程连接以
分类:数据库

一.概述

  上黄金时代章讲到了RPM安装后的文件目录,那章照旧介绍下安装步骤。也便从今以后做仿照效法吧。

  1. 移出centos 7系统自带的mysql库

  yum remove mysql-libs 

将项目部署到阿里云服务器ECS总结,远程连接以及大小写问题。    澳门新萄京 1

  2. 将下载的mysql包放到/home/hsr/tool 目录下(mysql-5.7.20-1.el7.x86_64.rpm-bundle.tar)
   澳门新萄京 2
  3. 解压到mysql文件夹下的rpm包
    澳门新萄京 3

  4.必备的4个rpm安装

  rpm -ivh mysql-community-common-5.7.20-1.el7.x86_64.rpm

    澳门新萄京 4

rpm -ivh mysql-community-libs-5.7.20-1.el7.x86_64.rpm

    澳门新萄京 5

rpm -ivh mysql-community-client-5.7.20-1.el7.x86_64.rpm

    澳门新萄京 6

rpm -ivh mysql-community-server-5.7.20-1.el7.x86_64.rpm

    澳门新萄京 7
  5. 查看服务境况
     澳门新萄京 8
  6.翻看伊始密码

cat /var/log/mysqld.log | grep password

    澳门新萄京 9
  7.复制出密码登入
    澳门新萄京 10
  8. 更改密码
    登陆成功后在开创Curry会提醒如下:
    澳门新萄京 11

SET PASSWORD = PASSWORD('js*2015');

    澳门新萄京 12

    上海图书馆Reset密码时:提醒您当前的密码不切合政策供给,相当于太简单。把密码品级设到最低

set global validate_password_policy=0;

    澳门新萄京 13
    再重新初始化密码:

SET PASSWORD = PASSWORD('js*2015%');

    澳门新萄京 14
  9.允许远程连接

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'js*2015%' WITH GRANT OPTION;  

    澳门新萄京 15
  那样,大家就能够在windowsComputer上用mysql顾客端远程连接linux上的mysql服务了。假若在windowsComputer上连接不了,先用telnet 来拼下ip和端口,检查防火墙

 

 

1.透过Intellij Idea 将品种打包成war 包

生成war包过程:

澳门新萄京 16

包装步骤

扭转后的war 包地点: /项目名/out/项目名_war/项目名_war.war

澳门新萄京 17

变动后的war 包

linux安装mysql全纪录[包蕴yum和rpm安装,编码,远程连接甚至大小写标题]

Centos版本 7.0 MySql版本5.7.19

第一步:下载mysql的rpm包

wget http://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm

第二步:安装mysql的rpm包

rpm -ivh mysql57-community-release-el7-11.noarch.rpm

第三步:使用yum安装mysql

yum install mysql-community-server

第四步:启动mysql服务

service mysqld restart

第五步:查看mysql生成的妄动密码,复制密码

grep "password" /var/log/mysqld.log

第六步:使用密码登陆本机mysql服务器(note:enter the password you copied at the previous卡塔尔国

mysql -uroot -p

第七步:在mysql中改正root登陆密码(note:借使提示Your password does not satisfy the current policy requirements,只需追加密码复杂度就能够)

use mysql;

SET password=PASSWORD("your custom password");

第八步:开启容许远程访谈:

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'your custom password' WITH GRANT OPTION;

第九步:重启mysql服务器:

service mysqld restart

  随着云服务器的广泛,购入云服务器的三昧更加的低,对二个技师来讲,很四个人会买卖大器晚成款云服务器。早先买过五年windows服务器(未有啥实际用场,便是为着玩),近来有空子接触一下linux服务器,选拔了系统为centos7的Ali云服务器,上边和贵裔一块来学学一下linux服务器的各类操作(纯新手)。

2. 通过SSH Secure File Transfer 连接到远程服务器

获得云服务器ECS 的公网ip地址,乃至登入名和登陆密码(即远程CentOS服务器上的客商名和登入密码)

澳门新萄京 18

接二连三到长途服务器

连天到调整台

澳门新萄京 19

4.gif

生龙活虎、查看mysql是或不是业已安装

利用“whereis mysql”命令来查看mysql安装路径:

[root@hadoop01 ~]# whereis mysql
mysql: /usr/bin/mysql /usr/lib64/mysql /usr/share/mysql /usr/share/man/man1/mysql.1.gz

 

使用前提是您的MySQL不是解压版的,而是rpm包恐怕使用yum命令安装的;

备注:“whereis”命令用于查看软件的设置路线。

选拔“rpm –qa|grep mysql”查看安装了什么MySQL的rpm包:

[root@hadoop01 ~]# rpm -qa|grep mysql
mysql-community-common-5.6.35-2.el6.x86_64
mysql-community-libs-5.6.35-2.el6.x86_64
mysql-community-release-el6-5.noarch
mysql-community-client-5.6.35-2.el6.x86_64
mysql-community-server-5.6.35-2.el6.x86_64

 

安装以上之后仍然不可能远程连接时,根据以下步骤分别逐个审查:

  个人对linux服务器的问询,java开采的主次三大件事apache tomcat mysql(那些领悟或许有误,我是.net开拓),出手的首先件是安装mysql数据库。

3. CentOS 上安装 jdk1.8

二、卸载MySQL

[root@hadoop01 ~]# rpm -qa|grep mysql      先查看mysql的安装包有哪些
mysql-community-release-el6-5.noarch
mysql-community-common-5.6.26-2.el6.i686
[root@hadoop01 ~]# yum remove mysql-community-release-el6-5.noarch mysql-community-common-5.6.26-2.el6.i686   删除安装包
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Remove Process
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-common.i686 0:5.6.26-2.el6 will be erased
---> Package mysql-community-release.noarch 0:el6-5 will be erased
--> Finished Dependency Resolution

Dependencies Resolved

=======================================================================================================================
 Package                     Arch          Version             Repository                                  Size
=======================================================================================================================
Removing:
 mysql-community-common      i686          5.6.26-2.el6        installed                                   2.1 M
 mysql-community-release     noarch        el6-5               @/mysql-community-release-el6-5.noarch      4.3 k

Transaction Summary
=======================================================================================================================
Remove        2 Package(s)

Installed size: 2.1 M
Is this ok [y/N]: y                 输入y,确定
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Erasing    : mysql-community-release-el6-5.noarch                          1/2 
  Erasing    : mysql-community-common-5.6.26-2.el6.i686                      2/2 
  Verifying  : mysql-community-common-5.6.26-2.el6.i686                      1/2 
  Verifying  : mysql-community-release-el6-5.noarch                          2/2 

Removed:
  mysql-community-common.i686 0:5.6.26-2.el6             mysql-community-release.noarch 0:el6-5                                          

Complete!
[root@hadoop01 ~]# rpm -qa|grep mysql        再次查看mysql的安装包
[root@hadoop01 ~]#

除去大家在mysql中创设的数据库:

MySQL创制的数据库日常坐落于“/var/lib/mysql”目录下,将“/var/lib/mysq”目录删除就能够,否则在装置新的MySQL的时候,它发掘早就有数据库了,就不会创制新的数据库了。

1.翻看端口监听情形

netstat -tulpen
#如果没有显示如下:
#tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN      27         121559     13509/mysqld
#证明监听不正确,输入如下:
vi `find / -name my.conf`
#然后在配置文件末尾添加:
bind-address = 0.0.0.0
#保存后重启mysql 
service mysqld restart

  首先用xshell连选用centos7,第四回跻身多少不适应,究竟用windows系统习于旧贯了。

下载

为了操作方便,在windows上下载好 jdk 的 压缩包,通过 SSH file transfer 拖进 远程服务器中

jdk1.8下载地址

注意:选择 jdk-8u144-linux-x64.tar.gz 等以 tar.gz 结尾压缩包

将压缩包复制到远程CentOS系统中

三、安装mysql

2.将端口3306参卫戍火墙:

sudo firewall-cmd --zone=public --permanent --add-service=mysql

  澳门新萄京 20  

安装配置jdk

1)查看当前Linux系统是还是不是早就设置java

rpm -qa | grep java

2)卸载已部分 java

rpm -e --nodeps 安装包名

3)安装jdk运维须求的插件

yum install glibc.i686

4 ) 解压jdk到/usr/local下

 tar –xvf  jdk-8u144-linux-x64.tar.gz –C /usr/local

5)配置jdk景况变量,张开/etc/profile安插文件,将上边配置拷贝进去

#set java environment
JAVA_HOME=/usr/local/jdk1.8.0_144
CLASSPATH=.:$JAVA_HOME/lib/tools.jar
PATH=$JAVA_HOME/bin:$PATH
export JAVA_HOME CLASSPATH PATH

6 卡塔尔国 重新加载/etc/profile安插文件

source /etc/profile

1.下载MySQL安装包

大家那边设置的mysql的本子是6.5。

MySQL的设置形式有三种,蓬蓬勃勃种是用yum安装,yum会自动联网下载rpm包实行安装;风华正茂种是用rpm命令安装,要求团结手动下载MySQL的rmp安装包。大家那边先介绍使用yum安装格局。

第意气风发到oracle官方网址下载“mysql-community-release-el6-5.noarch.rpm”,该公文超小,是MySQL的yum源包,里面只是记录了MySQL的yum地址。

澳门新萄京 21

 

3.重启防火墙:

sudo systemctl restart firewalld

  澳门新萄京 22

4.安装MySql 5.7

出于MySQL被Oracle收购,所以从Centos7从头不再暗中认可安装mysql而用Mariadb代替,要求接收一些方法技术科学安装Mysql

2.安装mysql的yum仓库

将下载的源“mysql-community-release-el6-5.noarch.rpm”上传到linux服务器,使用yum命令安装此源:

yum localinstall mysql-community-release-el6-5.noarch.rpm

 

[root@hadoop01 mysql]# ll
total 12
drwxr-xr-x. 2 root root 4096 Dec  7 04:34 mysql5.6-rpm
-rw-r--r--. 1 root root 5824 Aug  1  2015 mysql-community-release-el6-5.noarch.rpm
[root@hadoop01 mysql]# yum localinstall mysql-community-release-el6-5.noarch.rpm 
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Local Package Process
Examining mysql-community-release-el6-5.noarch.rpm: mysql-community-release-el6-5.noarch
Marking mysql-community-release-el6-5.noarch.rpm to be installed
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-release.noarch 0:el6-5 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===========================================================================================================
 Package                       Arch       Version    Repository                             Size
===========================================================================================================
Installing:
 mysql-community-release       noarch     el6-5      /mysql-community-release-el6-5.noarch  4.3 k

Transaction Summary
===========================================================================================================
Install       1 Package(s)

Total size: 4.3 k
Installed size: 4.3 k
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : mysql-community-release-el6-5.noarch                 1/1 
  Verifying  : mysql-community-release-el6-5.noarch                 1/1 

Installed:
  mysql-community-release.noarch 0:el6-5

Complete!
[root@hadoop01 mysql]#

  名称写贰个融洽向往的,主机填写云服务器公网ip,客户名填root,密码填写建服务器时设置的密码(忘记的话去Ali云上改变)。

1.首先查看是不是有Mariadb,有则卸载玛丽亚db,不然安装Mysql会发生冲突
rpm –qa | grep mariadb #查看mariadb安装包  
rpm -e --nodeps mariadb-libs-xxxxxxxxx.  #卸载mariadb 

自己商量系统自带的MySQL及相关RPM包,是不是安装

rpm -qa | grep -i mysql

设若有安装,则移除(rpm –e 名称)

yum -y remove mysql

3.安装mysql

yum install mysql-server

 

实施此命令在此以前,必需确定保证linux虚构机能够三番一遍到外网,不然是安装不成的,只要可以连上国外国语大学网,安装就不会卓殊,下面是设置的记录:

[root@hadoop01 mysql]# yum install mysql-server
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Loading mirror speeds from cached hostfile
c6-media                                       | 4.0 kB     00:00     
mysql-connectors-community                     | 2.5 kB     00:00     
mysql-connectors-community/primary_db          |  13 kB     00:00     
mysql-tools-community                          | 2.5 kB     00:00     
mysql-tools-community/primary_db               |  34 kB     00:00     
mysql56-community                              | 2.5 kB     00:00     
mysql56-community/primary_db                   | 176 kB     00:00     
Package mysql-server is obsoleted by mysql-community-server, trying to install mysql-community-server-5.6.35-2.el6.x86_64 instead
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-server.x86_64 0:5.6.35-2.el6 will be installed
--> Processing Dependency: mysql-community-common(x86-64) = 5.6.35-2.el6 for package: mysql-community-server-5.6.35-2.el6.x86_64
--> Processing Dependency: mysql-community-client(x86-64) >= 5.6.10 for package: mysql-community-server-5.6.35-2.el6.x86_64
--> Processing Dependency: perl(DBI) for package: mysql-community-server-5.6.35-2.el6.x86_64
--> Running transaction check
---> Package mysql-community-client.x86_64 0:5.6.35-2.el6 will be installed
--> Processing Dependency: mysql-community-libs(x86-64) >= 5.6.10 for package: mysql-community-client-5.6.35-2.el6.x86_64
---> Package mysql-community-common.x86_64 0:5.6.35-2.el6 will be installed
---> Package perl-DBI.x86_64 0:1.609-4.el6 will be installed
--> Running transaction check
---> Package mysql-community-libs.x86_64 0:5.6.35-2.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=================================================================================================
 Package                      Arch         Version           Repository             Size
=================================================================================================
Installing:
 mysql-community-server       x86_64       5.6.35-2.el6      mysql56-community      54 M
Installing for dependencies:
 mysql-community-client       x86_64       5.6.35-2.el6      mysql56-community      18 M
 mysql-community-common       x86_64       5.6.35-2.el6      mysql56-community      308 k
 mysql-community-libs         x86_64       5.6.35-2.el6      mysql56-community      1.9 M
 perl-DBI                     x86_64       1.609-4.el6       c6-media               705 k

Transaction Summary
=================================================================================================
Install       5 Package(s)

Total download size: 75 M
Installed size: 336 M
Is this ok [y/N]: y
Downloading Packages:
(1/5): mysql-community-client-5.6.35-2.el6.x86_64.rpm           |  18 MB     00:19     
(2/5): mysql-community-common-5.6.35-2.el6.x86_64.rpm           | 308 kB     00:00     
(3/5): mysql-community-libs-5.6.35-2.el6.x86_64.rpm             | 1.9 MB     00:02     
(4/5): mysql-community-server-5.6.35-2.el6.x86_64.rpm           |  54 MB     01:17     
(5/5): perl-DBI-1.609-4.el6.x86_64.rpm                          | 705 kB     00:00     
-------------------------------------------------------------------------------------------------
Total                                                           767 kB/s |  75 MB     01:40     
warning: rpmts_HdrFromFdno: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Retrieving key from file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Importing GPG key 0x5072E1F5:
 Userid : MySQL Release Engineering <mysql-build@oss.oracle.com>
 Package: mysql-community-release-el6-5.noarch (@/mysql-community-release-el6-5.noarch)
 From   : file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Is this ok [y/N]: y
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : mysql-community-common-5.6.35-2.el6.x86_64                  1/5 
  Installing : mysql-community-libs-5.6.35-2.el6.x86_64                    2/5 
  Installing : mysql-community-client-5.6.35-2.el6.x86_64                  3/5 
  Installing : perl-DBI-1.609-4.el6.x86_64                                 4/5 
  Installing : mysql-community-server-5.6.35-2.el6.x86_64                  5/5 
warning: /etc/my.cnf created as /etc/my.cnf.rpmnew
  Verifying  : mysql-community-client-5.6.35-2.el6.x86_64                  1/5 
  Verifying  : mysql-community-common-5.6.35-2.el6.x86_64                  2/5 
  Verifying  : mysql-community-libs-5.6.35-2.el6.x86_64                    3/5 
  Verifying  : mysql-community-server-5.6.35-2.el6.x86_64                  4/5 
  Verifying  : perl-DBI-1.609-4.el6.x86_64                                 5/5 

Installed:
  mysql-community-server.x86_64 0:5.6.35-2.el6                             

Dependency Installed:
  mysql-community-client.x86_64 0:5.6.35-2.el6 
  mysql-community-common.x86_64 0:5.6.35-2.el6 
  mysql-community-libs.x86_64 0:5.6.35-2.el6 
  perl-DBI.x86_64 0:1.609-4.el6

Complete!
[root@hadoop01 mysql]# rpm -qa|grep mysql    查看已经安装的mysql的rpm包
mysql-community-common-5.6.35-2.el6.x86_64
mysql-community-libs-5.6.35-2.el6.x86_64
mysql-community-release-el6-5.noarch
mysql-community-client-5.6.35-2.el6.x86_64
mysql-community-server-5.6.35-2.el6.x86_64
[root@hadoop01 mysql]# whereis mysql     查看mysql安装的路径
mysql: /usr/bin/mysql /usr/lib64/mysql /usr/share/mysql /usr/share/man/man1/mysql.1.gz
[root@hadoop01 mysql]#
[root@hadoop01 mysql]# ls /var/lib/mysql     我们创建的数据库都会存储在这个目录下面
[root@hadoop01 mysql]#

 

 

  步向多少个黑框中(未有桌面是还是不是有一些蒙)。

2.下载安装 mysq57 的 rpm 包

从官方网址下载 rpm 包mysql57-community-release-el7-11.noarch.rpm,并从windows 复制到 CentOS 服务器上

澳门新萄京 23

image.png

复制到CentOS服务器后,安装 rpm 包

rpm -ivh mysql57-community-release-el7-11.noarch.rpm

四、启动MySQL服务

启动mysql的命令:service mysqld status

 

安装完mysql之后,它便是三个名字为“mysqld”的劳动了,大家运营那些mysql服务就能够。

 

上边是开发银行mysql服务的长河:

[root@hadoop01 mysql]# service mysqld status   查看mysql服务的状态
mysqld is stopped
[root@hadoop01 mysql]# service mysqld start    启动mysql服务
Initializing MySQL database[开始初始化mysql数据库]
:  2017-01-30 17:29:29 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. 
Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-01-30 17:29:29 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
2017-01-30 17:29:29 0 [Note] /usr/sbin/mysqld (mysqld 5.6.35) starting as process 3652 ...
2017-01-30 17:29:29 3652 [Note] InnoDB: Using atomics to ref count buffer pool pages
2017-01-30 17:29:29 3652 [Note] InnoDB: The InnoDB memory heap is disabled
2017-01-30 17:29:29 3652 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2017-01-30 17:29:29 3652 [Note] InnoDB: Memory barrier is not used
2017-01-30 17:29:29 3652 [Note] InnoDB: Compressed tables use zlib 1.2.3
2017-01-30 17:29:29 3652 [Note] InnoDB: Using Linux native AIO
2017-01-30 17:29:29 3652 [Note] InnoDB: Using CPU crc32 instructions
2017-01-30 17:29:29 3652 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2017-01-30 17:29:29 3652 [Note] InnoDB: Completed initialization of buffer pool
2017-01-30 17:29:29 3652 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2017-01-30 17:29:29 3652 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2017-01-30 17:29:29 3652 [Note] InnoDB: Database physically writes the file full: wait...
2017-01-30 17:29:30 3652 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2017-01-30 17:29:30 3652 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2017-01-30 17:29:31 3652 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2017-01-30 17:29:31 3652 [Warning] InnoDB: New log files created, LSN=45781
2017-01-30 17:29:31 3652 [Note] InnoDB: Doublewrite buffer not found: creating new
2017-01-30 17:29:31 3652 [Note] InnoDB: Doublewrite buffer created
2017-01-30 17:29:31 3652 [Note] InnoDB: 128 rollback segment(s) are active.
2017-01-30 17:29:31 3652 [Warning] InnoDB: Creating foreign key constraint system tables.
2017-01-30 17:29:31 3652 [Note] InnoDB: Foreign key constraint system tables created
2017-01-30 17:29:31 3652 [Note] InnoDB: Creating tablespace and datafile system tables.
2017-01-30 17:29:31 3652 [Note] InnoDB: Tablespace and datafile system tables created.
2017-01-30 17:29:31 3652 [Note] InnoDB: Waiting for purge to start
2017-01-30 17:29:31 3652 [Note] InnoDB: 5.6.35 started; log sequence number 0
2017-01-30 17:29:32 3652 [Note] Binlog end
2017-01-30 17:29:32 3652 [Note] InnoDB: FTS optimize thread exiting.
2017-01-30 17:29:32 3652 [Note] InnoDB: Starting shutdown...
2017-01-30 17:29:33 3652 [Note] InnoDB: Shutdown completed; log sequence number 1625977


2017-01-30 17:29:33 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. 
Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-01-30 17:29:33 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
2017-01-30 17:29:33 0 [Note] /usr/sbin/mysqld (mysqld 5.6.35) starting as process 3674 ...
2017-01-30 17:29:33 3674 [Note] InnoDB: Using atomics to ref count buffer pool pages
2017-01-30 17:29:33 3674 [Note] InnoDB: The InnoDB memory heap is disabled
2017-01-30 17:29:33 3674 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2017-01-30 17:29:33 3674 [Note] InnoDB: Memory barrier is not used
2017-01-30 17:29:33 3674 [Note] InnoDB: Compressed tables use zlib 1.2.3
2017-01-30 17:29:33 3674 [Note] InnoDB: Using Linux native AIO
2017-01-30 17:29:33 3674 [Note] InnoDB: Using CPU crc32 instructions
2017-01-30 17:29:33 3674 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2017-01-30 17:29:33 3674 [Note] InnoDB: Completed initialization of buffer pool
2017-01-30 17:29:33 3674 [Note] InnoDB: Highest supported file format is Barracuda.
2017-01-30 17:29:33 3674 [Note] InnoDB: 128 rollback segment(s) are active.
2017-01-30 17:29:33 3674 [Note] InnoDB: Waiting for purge to start
2017-01-30 17:29:33 3674 [Note] InnoDB: 5.6.35 started; log sequence number 1625977
2017-01-30 17:29:33 3674 [Note] Binlog end
2017-01-30 17:29:33 3674 [Note] InnoDB: FTS optimize thread exiting.
2017-01-30 17:29:33 3674 [Note] InnoDB: Starting shutdown...
2017-01-30 17:29:35 3674 [Note] InnoDB: Shutdown completed; log sequence number 1625987



[你要记住为root用户设置一个密码!]
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

  /usr/bin/mysqladmin -u root password 'new-password'
  /usr/bin/mysqladmin -u root -h hadoop01 password 'new-password'

Alternatively you can run:

  /usr/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

Please report any problems at http://bugs.mysql.com/

The latest information about MySQL is available on the web at

  http://www.mysql.com

Support MySQL by buying support/licenses at http://shop.mysql.com

Note: new default config file not created.
Please make sure your config file is current

WARNING: Default config file /etc/my.cnf exists on the system
This file will be read by default by the MySQL server
If you do not want to use this, either remove it, or use the
--defaults-file argument to mysqld_safe when starting the server

[  OK  ]
Logging to '/var/lib/mysql/hadoop01.err'.
Starting mysqld:  [  OK  ]
[root@hadoop01 mysql]# service mysqld status   再次查看mysql服务的状态
mysqld (pid  3839) is running...
[root@hadoop01 mysql]#

 

 

  下边起始走入正题,安装mysql数据库,首先检查一下服务器上有未有安装mysql数据库,

3.装置mysql境遇及其依赖包
yum install mysql mysql-server mysql mysql-devel  

五、 设置root顾客的密码

为root用户设置密码,然后使用root用户连接mysql服务器:

[root@hadoop01 mysql]# /usr/bin/mysqladmin -u root password 'root'    为root用户设置密码
Warning: Using a password on the command line interface can be insecure.
[root@hadoop01 mysql]# mysql -uroot –proot   使用root用户连接mysql服务器
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 3
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> show databases;    查看数据库列表
 -------------------- 
| Database           |
 -------------------- 
| information_schema |
| mysql              |
| performance_schema |
 -------------------- 
3 rows in set (0.00 sec)

mysql>

 

  1.在命令框中数据 rpm -qa|grep mysql,什么都未有现身,表示还未设置mysql

4.启动mysql 服务
systemctl start mysqld.service #启动mysql服务  
systemctl enable mysqld.service #设置开机启动mysql服务  

六、 远程连接MySQL服务器

长间距连接mysql数据库

小编们想行使Navicat for MySQL连接mysql数据库服务器,现身如下错误提示:

澳门新萄京 24

乖谬提醒:不准远程连接mysql数据库服务器!须要授权本事访问。

Mysql的长间隔连接授权:

 

[root@hadoop01 mysql]# mysql -uroot -proot
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 6
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> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;
Query OK, 0 rows affected (0.01 sec)

mysql>

再度远程连接mysql服务器:

澳门新萄京 25

RPM包安装情势:

假定您的Computer不能够联网的话,就不能够使用yum的方法来设置mysql的劳务了, 能够行使仿效资料中的mysql-rpm文件夹下的mysql安装包来安装。

[root@bogon mysql-rpm]# rpm -ivh mysql-community-*

 

安装后,运维服务、设置密码、远程授权后不只能够使用。

   澳门新萄京 26

5.登录mysql

出于 mysql 5.7 版本在设置时会成立随机密码,故得先找到该密码
位置: /var/log/mysqld.log

vim /var/log/mysqld.log

澳门新萄京 27

轻松变化的密码

mysql -u root -p
Enter password:     #输入生成的随机密码

七、字符编码难题

笔者们的mysql数据库创立好了,先看上边包车型客车叁个难点:

[root@hadoop01 ~]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 4
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> show databases;
 -------------------- 
| Database           |
 -------------------- 
| information_schema |
| mysql              |
| performance_schema |
 -------------------- 
3 rows in set (0.03 sec)

mysql> create database xuebusi;
Query OK, 1 row affected (0.00 sec)

mysql> show databases;
 -------------------- 
| Database           |
 -------------------- 
| information_schema |
| mysql              |
| performance_schema |
| xuebusi            |
 -------------------- 
4 rows in set (0.00 sec)

mysql> use xuebusi;
Database changed
mysql> create table tb1(id bigint, name varchar(250));
Query OK, 0 rows affected (0.09 sec)

mysql> show tables;
 ------------------- 
| Tables_in_xuebusi |
 ------------------- 
| tb1               |
 ------------------- 
1 row in set (0.00 sec)

mysql> insert into tb1 values(1, 'zhangsan');
Query OK, 1 row affected (0.05 sec)

mysql> select * from tb1;
 ------ ---------- 
| id   | name     |
 ------ ---------- 
|    1 | zhangsan |
 ------ ---------- 
1 row in set (0.00 sec)

mysql> insert into tb1 values(2, '李四');
ERROR 1366 (HY000): Incorrect string value: 'xE6x9Dx8ExE5x9Bx9B' for column 'name' at row 1
mysql>

在上头的笔录中,大家采用命令行简单创设了贰个xubusi数据库,并创造了一张名叫tb1的表,插入克罗地亚语的数量是从未难点的,不过插入汉语时报错了:

ERROR 1366 (HY000): Incorrect string value: 'xE6x9Dx8ExE5x9Bx9B' for column 'name' at row 1

 

乐趣是说,name那几个字段插入了二个不合规的值。

怎么插入普通话就非法了啊?

因为大家建表的时候,没有为name那个字段内定字符集,所以它默许使用的字符集是“latin1”。

开辟Navicat for MySQL工具,在tb1表名上边单击鼠标右键选择“设计表”,选中“name”这一列,在江湖就能够显得该列对应的字符集:

澳门新萄京 28

在建表的时候大家本来可以为每三个字段钦点字符集,若无一些名的话,varchar类型的字段的暗许字符集正是“latin1”。前边须求把它手动改善成“utf8”,工夫插入中文。

 

非但字段有暗中认可的字符集,表也会有暗中同意的字符集,若是建表时未有为表钦定字符集,表的暗中认可字符集也是“latin1”,大家也要把表的字符集也手动改过为utf8:

 澳门新萄京 29

澳门新萄京 30

翻开mysql的默许字符集并更正:

[root@hadoop01 ~]# vi /etc/my.cnf      修改mysql的默认字符集
character_set_database=utf8
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html

[client]     新增[client]标签
default-character-set=utf8            新增此配置
[mysqld]
default-storage-engine=INNODB       新增此配置
character-set-server=utf8             新增此配置
collation-server=utf8_general_ci       新增此配置

# 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

# These are commonly set, remove the # and set as required.
# basedir = .....
# datadir = .....
# port = .....
# server_id = .....
# socket = .....

# 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
#lower_case_table_names=1
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

~
~
~
"/etc/my.cnf" 34L, 1094C written
[root@hadoop01 ~]# service mysqld restart    重启mysql服务
Stopping mysqld:  [  OK  ]
Starting mysqld:  [  OK  ]
[root@hadoop01 ~]# cat /etc/my.cnf          查看修改后的字符集
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html

[client]
default-character-set=utf8
[mysqld]
default-storage-engine=INNODB
character-set-server=utf8
collation-server=utf8_general_ci

# 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

# These are commonly set, remove the # and set as required.
# basedir = .....
# datadir = .....
# port = .....
# server_id = .....
# socket = .....

# 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 
#lower_case_table_names=1
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 

[root@hadoop01 ~]#

 

mysql> show variables like '%char%';   未修改编码之前,查看字符集设置如下:
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id:    2
Current database: xuebusi

 -------------------------- ---------------------------- 
| Variable_name            | Value                      |
 -------------------------- ---------------------------- 
| character_set_client     | utf8                       |
| character_set_connection | utf8                       |
| character_set_database   | latin1                     |
| character_set_filesystem | binary                     |
| character_set_results    | utf8                       |
| character_set_server     | utf8                       |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
 -------------------------- ---------------------------- 
8 rows in set (0.01 sec)

mysql> exit;      修改/etc/my.cnf文件后,退出命令行,重新登录
Bye
[root@hadoop01 ~]# mysql -uroot –p             重新登录
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 2
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> show variables like '%char%';              再次查看字符集设置,都改成utf8了
 -------------------------- ---------------------------- 
| Variable_name            | Value                      |
 -------------------------- ---------------------------- 
| character_set_client     | utf8                       |
| character_set_connection | utf8                       |
| character_set_database   | utf8                       |
| character_set_filesystem | binary                     |
| character_set_results    | utf8                       |
| character_set_server     | utf8                       |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
 -------------------------- ---------------------------- 
8 rows in set (0.00 sec)

修改了mysql的默认字符集之后,我们使用命令行来创建数据库和表来看一下默认的建库和建表的字符集:

mysql> show databases;
 -------------------- 
| Database           |
 -------------------- 
| information_schema |
| mysql              |
| performance_schema |
| xuebusi            |
 -------------------- 
4 rows in set (0.00 sec)

mysql> create database db_1;   创建一个db_1数据库
Query OK, 1 row affected (0.01 sec)

mysql> show create database db_1;      查看建库的sql语句
 ---------- --------------------------------------------------------------- 
| Database | Create Database                                               |
 ---------- --------------------------------------------------------------- 
| db_1     | CREATE DATABASE `db_1` /*!40100 DEFAULT CHARACTER SET utf8 */ |   此时数据库默认的建库字符集编码是utf8编码
 ---------- --------------------------------------------------------------- 
1 row in set (0.00 sec)

mysql> use db_1;     
Database changed
mysql> create table tb_1(id int(10),name varchar(50));      在db_1数据库中创建tb_1表
Query OK, 0 rows affected (0.06 sec)

mysql> show create table tb_1;      查看tb_1表的建表SQL语句
 ------- ---------------------------------------------------- 
| Table | Create Table                                       |
 ------- ---------------------------------------------------- 
| tb_1  | CREATE TABLE `tb_1` (
  `id` int(10) DEFAULT NULL,
  `name` varchar(50) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 |         此时默认的建表字符集是utf8编码
 ------- ---------------------------------------------------- 
1 row in set (0.00 sec)

mysql>

 

澳门新萄京 31

 

 

澳门新萄京 32

 

唯独,即使利用Navicat for MySQL工具建库或许建表的话,必要手动钦赐表和字段的编码。

 

由此Navicat for MySQL建库的时候,须手动内定数据库的字符编码:

澳门新萄京 33

 

要翻开已经创办好的数据库的字符编码,能够在表名上点击鼠标右键,选拔“数据库属性”,在弹出的窗口中能够查阅。

 

经过Navicat for MySQL建表时,不用为每一字段都钦命字符编码,在保存表以前,切换的“选项”那么些选项卡中,能够手动设置表的字符编码为utf8编码,然后再保存:

澳门新萄京 34

查看已经创办好的表个建表sql语句,能够在表名上点击数据右键,选拔“对象新闻”,再点击“DDL”选项卡,就能够见见建表sql语句了:

澳门新萄京 35

在Navicat for MySQL中往“db_2”数据库的“tb_2”中插入几条数据,包含粤语:

澳门新萄京 36

通过命令行来查看“db_澳门新萄京,2”数据库的“tb_2”中数量,普通话突显也是常规的:

mysql> show databases;
 -------------------- 
| Database           |
 -------------------- 
| information_schema |
| db_1               |
| db_2               |
| mysql              |
| performance_schema |
| xuebusi            |
 -------------------- 
6 rows in set (0.00 sec)

mysql> use db_2;
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_db_2 |
 ---------------- 
| tb_2           |
 ---------------- 
1 row in set (0.00 sec)

mysql> select * from tb_2;
 ---- ---------- 
| id | name     |
 ---- ---------- 
|  1 | zhangsan |
|  2 | 李四     |
|  3 | 王五     |
 ---- ---------- 
3 rows in set (0.00 sec)

mysql>

  由于centos7采纳的是Mariadb,所以实践yum install mysql命令只是更新Mariadb数据库(具体是怎么不懂,笔者是设置好多次后搜出来的)

6.更正密码
mysql>ALTER USER USER() IDENTIFIED BY '12345678'

实行后报错:

ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

原因:mysql 5.7 对密码的复杂有了需要
杀绝方法:

mysql> set global validate_password_policy=0;
mysql> set global validate_password_length=4;  
mysql> ALTER USER USER() IDENTIFIED BY '12345678';

八、关于大小写标题

在windows下,mysql不区分朗朗上口写,而在linux下,mysql是从严区分轻重缓急写的。

 

看下边包车型客车建表sql语句,建表时钦点的表名是大写的“TB_3”,往表中插入数据以致查询表数据的时候也要确定保障表名是大写的“TB_3”,不然会报错:

 

mysql> CREATE TABLE `TB_3` (
    ->   `ID` bigint(20) NOT NULL,
    ->   `NAME` varchar(255) DEFAULT NULL,
    ->   PRIMARY KEY (`ID`)
    -> ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Query OK, 0 rows affected (0.04 sec)

mysql> insert into tb_3 values(1, '李四');
ERROR 1146 (42S02): Table 'db_2.tb_3' doesn't exist
mysql> insert into TB_3 values(1, '李四');
Query OK, 1 row affected (0.01 sec)

mysql> select * from tb_3;
ERROR 1146 (42S02): Table 'db_2.tb_3' doesn't exist
mysql> select * from TB_3;
 ---- -------- 
| ID | NAME   |
 ---- -------- 
|  1 | 李四   |
 ---- -------- 
1 row in set (0.00 sec)

mysql> show variables like '
			

本文由澳门新萄京发布于数据库,转载请注明出处:将项目部署到阿里云服务器ECS总结,远程连接以

上一篇:从0开始搭建SQL 下一篇:没有了
猜你喜欢
热门排行
精彩图文