· 公网服务器
· 数据库
· 下载、安装、配置、远程连接
· 使用本地的Navicat去远程连接 操作数据库
· JDK 安装Tomcat的前提
· tomcat
·目录结构
· webapps
·放入你的项目
# 安装Centos的wget插件
yum install wget -y
# MySQL的选择网站:http://repo.mysql.com/ 网站有诸多版本,选择合适的下载即可。
# 如下,我选择的是MySQL5.7
wget http://repo.mysql.com/mysql57-community-release-el7-10.noarch.rpm
sudo rpm -ivh mysql57-community-release-el7-10.noarch.rpm
sudo yum install mysql-server
效果图如下:
效果图如下:
MySQL5.6
,安装后默认密码是为空的,可直接进入数据库的,Mysql5.7
就需要初始密码# 方式一: 查询初始密码:
mysql5.6安装后默认密码是为空的,可直接进入数据库的,但是mysql5.7就需要初始密码
2. cat /var/log/mysqld.log | grep password 查询MySQL5.7密码
3. [root@izb6rc3amsrxv6z local]# cat /var/log/mysqld.log | grep password
# 初始化密码: soadrod;c9Pr
2020-04-16T01:34:20.422336Z 1 [Note] A temporary password is generated for root@localhost: soadrod;c9Pr
2020-04-16T01:52:45.445074Z 0 [Note] Shutting down plugin 'sha256_password'
2020-04-16T01:52:45.445078Z 0 [Note] Shutting down plugin 'mysql_native_password'
2020-04-16T01:52:54.766386Z 2 [Note] Access denied for user 'root'@'localhost' (using password: NO)
2020-04-16T02:30:43.300676Z 0 [Note] Shutting down plugin 'validate_password'
2020-04-16T02:30:44.813774Z 0 [Note] Shutting down plugin 'sha256_password'
2020-04-16T02:30:44.813777Z 0 [Note] Shutting down plugin 'mysql_native_password'
2020-04-16T02:42:29.107064Z 0 [Note] Shutting down plugin 'validate_password'
2020-04-16T02:42:30.119448Z 0 [Note] Shutting down plugin 'sha256_password'
2020-04-16T02:42:30.119451Z 0 [Note] Shutting down plugin 'mysql_native_password'
2020-04-16T02:43:33.339551Z 0 [Note] Shutting down plugin 'sha256_password'
2020-04-16T02:43:33.339554Z 0 [Note] Shutting down plugin 'mysql_native_password'
2020-04-16T02:45:39.090209Z 0 [Note] Shutting down plugin 'validate_password'
2020-04-16T02:45:40.607605Z 0 [Note] Shutting down plugin 'sha256_password'
2020-04-16T02:45:40.607608Z 0 [Note] Shutting down plugin 'mysql_native_password'
2020-04-16T02:49:08.842072Z 0 [Note] Shutting down plugin 'sha256_password'
2020-04-16T02:49:08.842075Z 0 [Note] Shutting down plugin 'mysql_native_password'
2020-04-16T02:49:25.046531Z 0 [Note] Shutting down plugin 'sha256_password'
2020-04-16T02:49:25.046534Z 0 [Note] Shutting down plugin 'mysql_native_password'
2020-04-16T02:53:45.817187Z 8 [Note] Access denied for user 'root'@'localhost' (using password: YES)
2020-04-16T02:59:24.456338Z 14 [Note] Access denied for user 'root'@'223.96.218.217' (using password: YES)
2020-04-16T02:59:26.824028Z 15 [Note] Access denied for user 'root'@'223.96.218.217' (using password: YES)
[root@izb6rc3amsrxv6z local]#
4. 密码修改,代码如下
mysql> alter user 'root'@'localhost' identified by 'Admin123..';
---------------------------------------------------------------
# 方式二: 跳过权限验证
[root@izb6rc3amsrxv6z /]# 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
# 跳过MySQL的权限机制 就不需要输入密码 进去 更改密码 再将本命令删除 或 注释
skip-grant-tables
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# 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
# 以下是在重启数据库
# 尝试了老命令 发现不行 结果告诉我了一个新的命令“systemctl restart mysql.service”
[root@izb6rc3amsrxv6z etc]# service mysql restart
Redirecting to /bin/systemctl restart mysql.service
Failed to restart mysql.service: Unit not found.
# 重启数据库的服务
[root@izb6rc3amsrxv6z etc]# systemctl restart mysqld
# 1. 注意:在MySQL5.7版本又出现了不同的地方,即在mysql数据库中的user用户表中,没有password这个字段属性了,而是更改为了authentication_string
# 2. 修改语句如下:(下方的sorry则是我的数据库密码)
update mysql.user set authentication_string = password('sorry') where user = 'root';
centOS7下找回mysql的密码 | 忘记密码,这么办?
更改数据库密码步骤
1. 配置文件[/etc/my.cnf] 设置 跳过密码验证
2. 重启数据库服务
3. 进入数据库之后? 选中数据库 运行修改密码的语句
4. 退出 重启数据库
[root@izb6rc3amsrxv6z etc]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.29 MySQL Community Server (GPL)
Copyright (c) 2000, 2020, 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> update user set authentication_string = password('sorry') where user = 'root';
ERROR 1046 (3D000): No database selected
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)
# 选中数据库
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)
# 查询 user表的 表结构
mysql> desc user ;
+------------------------+-----------------------------------+------+-----+-----------------------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------------------+-----------------------------------+------+-----+-----------------------+-------+
| Host | char(60) | NO | PRI | | |
| User | char(32) | NO | PRI | | |
| Select_priv | enum('N','Y') | NO | | N | |
| Insert_priv | enum('N','Y') | NO | | N | |
| Update_priv | enum('N','Y') | NO | | N | |
| Delete_priv | enum('N','Y') | NO | | N | |
| Create_priv | enum('N','Y') | NO | | N | |
| Drop_priv | enum('N','Y') | NO | | N | |
| Reload_priv | enum('N','Y') | NO | | N | |
| Shutdown_priv | enum('N','Y') | NO | | N | |
| Process_priv | enum('N','Y') | NO | | N | |
| File_priv | enum('N','Y') | NO | | N | |
| Grant_priv | enum('N','Y') | NO | | N | |
| References_priv | enum('N','Y') | NO | | N | |
| Index_priv | enum('N','Y') | NO | | N | |
| Alter_priv | enum('N','Y') | NO | | N | |
| Show_db_priv | enum('N','Y') | NO | | N | |
| Super_priv | enum('N','Y') | NO | | N | |
| Create_tmp_table_priv | enum('N','Y') | NO | | N | |
| Lock_tables_priv | enum('N','Y') | NO | | N | |
| Execute_priv | enum('N','Y') | NO | | N | |
| Repl_slave_priv | enum('N','Y') | NO | | N | |
| Repl_client_priv | enum('N','Y') | NO | | N | |
| Create_view_priv | enum('N','Y') | NO | | N | |
| Show_view_priv | enum('N','Y') | NO | | N | |
| Create_routine_priv | enum('N','Y') | NO | | N | |
| Alter_routine_priv | enum('N','Y') | NO | | N | |
| Create_user_priv | enum('N','Y') | NO | | N | |
| Event_priv | enum('N','Y') | NO | | N | |
| Trigger_priv | enum('N','Y') | NO | | N | |
| Create_tablespace_priv | enum('N','Y') | NO | | N | |
| ssl_type | enum('','ANY','X509','SPECIFIED') | NO | | | |
| ssl_cipher | blob | NO | | NULL | |
| x509_issuer | blob | NO | | NULL | |
| x509_subject | blob | NO | | NULL | |
| max_questions | int(11) unsigned | NO | | 0 | |
| max_updates | int(11) unsigned | NO | | 0 | |
| max_connections | int(11) unsigned | NO | | 0 | |
| max_user_connections | int(11) unsigned | NO | | 0 | |
| plugin | char(64) | NO | | mysql_native_password | |
| authentication_string | text | YES | | NULL | |
| password_expired | enum('N','Y') | NO | | N | |
| password_last_changed | timestamp | YES | | NULL | |
| password_lifetime | smallint(5) unsigned | YES | | NULL | |
| account_locked | enum('N','Y') | NO | | N | |
+------------------------+-----------------------------------+------+-----+-----------------------+-------+
45 rows in set (0.00 sec)
# 更改数据库密码了
mysql> update mysql.user set authentication_string = password('sorry') where user = 'root';
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 1
mysql> exit
Bye
# 删除 【跳过数据库的登陆权限验证】 存在/etc/my.cnf
[root@izb6rc3amsrxv6z etc]# vi /etc/my.cnf
# 再次重启MySQL服务
[root@izb6rc3amsrxv6z etc]# systemctl restart mysqld
# 准备再次登录 数据库
[root@izb6rc3amsrxv6z etc]# mysql -uroot -p
# 没有输入密码,测试 是否可以进入 发现不行 ,表示更改密码生效
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
[root@izb6rc3amsrxv6z etc]# mysql -uroot -p
Enter password: #sorry
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.29
Copyright (c) 2000, 2020, 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 远程连接访问:
1. 如果想把密码的要求设置的简单一些时,可以按照如下截图操作:
2. 赋予root用户可以接收任意主机(%)访问
` grant all privileges on *.* to 'root'@'%' identified by 'Admin123..';`
3. 刷新权限 【单单赋予权限是不行的,一定要记得刷新操作】
`flush privileges;`
[root@izb6rc3amsrxv6z /]# yum install lrzsz -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package lrzsz.x86_64 0:0.12.20-36.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
============================================================================================
Package Arch Version Repository Size
======================================
Installing:
lrzsz x86_64 0.12.20-36.el7 base 78 k
Transaction Summary
======================================
Install 1 Package
Total download size: 78 k
Installed size: 181 k
Downloading packages:
lrzsz-0.12.20-36.el7.x86_64.rpm | 78 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : lrzsz-0.12.20-36.el7.x86_64 1/1
Verifying : lrzsz-0.12.20-36.el7.x86_64 1/1
Installed:
lrzsz.x86_64 0:0.12.20-36.el7
Complete!
[root@izb6rc3amsrxv6z /]#
[root@izb6rc3amsrxv6z /]# cd /www/develop/java
[root@izb6rc3amsrxv6z java]# ls
[root@izb6rc3amsrxv6z java]# rz -E
rz waiting to receive.
[root@izb6rc3amsrxv6z java]# ls
jdk-8u211-linux-x64.tar.gz
[root@izb6rc3amsrxv6z java]# tar -zxf jdk-8u211-linux-x64.tar.gz
[root@izb6rc3amsrxv6z java]# ls
jdk1.8.0_211 jdk-8u211-linux-x64.tar.gz
#配置jdk的环境变量 /etc/profile
#在 /etc/profile内的最后加上以上内容,路径下写你自己设置的路径
export JAVA_HOME=/www/develop/www/develop/java/jdk1.8.0_211
export PATH=$JAVA_HOME/bin:$PATH
#更新环境变量
[root@izb6rc3amsrxv6z java]# source /etc/profile
# 核查jdk是否安装成功 查看版本 查看javac有没有内容输出
[root@izb6rc3amsrxv6z java]# java -version
java version "1.8.0_211"
Java(TM) SE Runtime Environment (build 1.8.0_211-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.211-b12, mixed mode)
[root@izb6rc3amsrxv6z /]# cd /www/develop/tomcat
[root@izb6rc3amsrxv6z java]# ls
[root@izb6rc3amsrxv6z java]# rz -E
rz waiting to receive.
[root@izb6rc3amsrxv6z java]# ls
jdk-8u211-linux-x64.tar.gz
[root@izb6rc3amsrxv6z java]# tar -zxf jdk-8u211-linux-x64.tar.gz
[root@izb6rc3amsrxv6z java]# ls
jdk1.8.0_211 jdk-8u211-linux-x64.tar.gz
#配置jdk的环境变量 /etc/profile
#在 /etc/profile内的最后加上以上内容,路径下写你自己设置的路径
export PATH=$/www/develop/www/develop/apache/apache-tomcat-8.5.40/bin:$PATH
#更新环境变量
[root@izb6rc3amsrxv6z /]# source /etc/profile
#核查jdk是否安装成功 查看版本 查看javac有没有内容输出
[root@izb6rc3amsrxv6z java]# catalina.sh start
java version "1.8.0_211"
Java(TM) SE Runtime Environment (build 1.8.0_211-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.211-b12, mixed mode)