首页 > 数据库 >Linux服务器安装MySQL数据库

Linux服务器安装MySQL数据库

时间:2024-07-03 13:57:55浏览次数:15  
标签:QRTZ Linux sql mysql MySQL 服务器 validate password root

首先yum安装的版本比较低,所以先下载一个yum比较新的库文件
点击就是下载到本地,如果想在Linux里面下载就需要右击复制链接

在这里插入图片描述

1. 安装MySQL:

sudo apt update
sudo apt install mysql-server

2. 可以通过sudo systemctl status mysql命令查看MySQL是否已启动
3. 设置登录密码

root@***-virtual-machine:/etc/network# sudo mysql_secure_installation

Securing the MySQL server deployment.

Connecting to MySQL using a blank password.

VALIDATE PASSWORD COMPONENT can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD component?

Press y|Y for Yes, any other key for No: y
There are three levels of password validation policy:

LOW    Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary                  file

Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 1
Please set the password for root here.
  • 根据提示输入要设置的密码即可!
  • 接着会删除测试数据库并重置相关数据表,一直输Y即可!

4. Failed! Error: SET PASSWORD has no significance for user ‘root‘@‘localhost‘ as the authe…问题解决

  • 部分安装过程中会遇到上述问题,原因是刚开始设置的密码太简单
  • 先通过sudo mysql命令进入mysql
  • 在命令行中执行以下命令
#因为上面在密码策略处选择的1,所以默认的密码检查机制为特殊符号+大小写+数字
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password by '新密码';

mysql> SHOW VARIABLES LIKE 'validate_password%';
+--------------------------------------+--------+
| Variable_name                        | Value  |
+--------------------------------------+--------+
| validate_password.check_user_name    | ON     |
| validate_password.dictionary_file    |        |
| validate_password.length             | 8      |
| validate_password.mixed_case_count   | 1      |
| validate_password.number_count       | 1      |
| validate_password.policy             | MEDIUM |
| validate_password.special_char_count | 1      |
+--------------------------------------+--------+
7 rows in set (0.00 sec)

关于 mysql 密码策略相关参数;
1)、validate_password_length 固定密码的总长度;
2)、validate_password_dictionary_file 指定密码验证的文件路径;
3)、validate_password_mixed_case_count 整个密码中至少要包含大/小写字母的总个数;
4)、validate_password_number_count 整个密码中至少要包含阿拉伯数字的个数;
5)、validate_password_policy 指定密码的强度验证等级,默认为 MEDIUM;
关于 validate_password_policy 的取值:
0/LOW:只验证长度;
1/MEDIUM:验证长度、数字、大小写、特殊字符;
2/STRONG:验证长度、数字、大小写、特殊字符、字典文件;
6)、validate_password_special_char_count 整个密码中至少要包含特殊字符的个数;

  • 然后输入quitexit退出mysql回到终端命令行,输入:
sudo mysql_secure_installation

输入刚才的密码即可,出现的问题都选n.

root@***-virtual-machine:/home/***# `sudo mysql_secure_installation`

Securing the MySQL server deployment.

Enter password for user root: 
The 'validate_password' component is installed on the server.
The subsequent steps will run with the existing configuration
of the component.
Using existing password for root.

Estimated strength of the password: 100 
Change the password for root ? ((Press y|Y for Yes, any other key for No) : `n`

 ... skipping.
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) : `n`

 ... skipping.


Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : `n`

 ... skipping.
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.


Remove test database and access to it? (Press y|Y for Yes, any other key for No) : `n`

 ... skipping.
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) :` n`

 ... skipping.
All done! 

5. 登录:

  • sudo mysql
  • mysql -u root -p

6. 将sql语句的文件解压:

unzip -d /opt/init_sql init_sql.zip 

7. 执行SQL

#进入sql
mysql -u root -p
#创建数据库
mysql> create database community;
Query OK, 1 row affected (0.01 sec)
#选中数据库
mysql> use community
Database changed
#导入数据
mysql> source /opt/init_sql/init_schema.sql;
......
mysql> source /opt/init_sql/init_data.sql;
......
mysql> source /opt/init_sql/tables_mysql_innodb.sql;
......
#导入后查看表
mysql> show tables;
+--------------------------+
| Tables_in_community      |
+--------------------------+
| QRTZ_BLOB_TRIGGERS       |
| QRTZ_CALENDARS           |
| QRTZ_CRON_TRIGGERS       |
| QRTZ_FIRED_TRIGGERS      |
| QRTZ_JOB_DETAILS         |
| QRTZ_LOCKS               |
| QRTZ_PAUSED_TRIGGER_GRPS |
| QRTZ_SCHEDULER_STATE     |
| QRTZ_SIMPLE_TRIGGERS     |
| QRTZ_SIMPROP_TRIGGERS    |
| QRTZ_TRIGGERS            |
| comment                  |
| discuss_post             |
| login_ticket             |
| message                  |
| user                     |
+--------------------------+
16 rows in set (0.00 sec)
#接下来修改user表,因为用户表的头像地址使用的还是http://localhost..
mysql> update user set header_url = 'http://images.nowcoder.com/head/666t.png' where header_url like '%localhost%';
#搞定退出
mysql> exit
Bye
root@***-virtual-machine:/opt# 

标签:QRTZ,Linux,sql,mysql,MySQL,服务器,validate,password,root
From: https://blog.csdn.net/qq_52398432/article/details/140106043

相关文章

  • 简单课设:基于TCP协议的客户/服务器聊天室
            随着计算机的普及,网络编程也显得愈发重要,同时掌握实现客户/服务器程序的编写方法也不可忽视。通过学习,我们将了解TCP协议在网络通信中的重要性,掌握如何使用在Linux或Windows平台上编写简单的TCP客户/服务器程序。课程设计分为两个部分:服务器端和客户端。在服务......
  • 联想服务器阵列数据恢复Raid5/0/6数据库RaidZ/虚拟机
    针对联想服务器阵列数据恢复,特别是涉及RAID5/0/6、数据库RAIDZ以及虚拟机的情况一、RAID5/0/6数据恢复故障诊断确定故障类型:首先需要明确是RAID5/0/6阵列中的哪一部分出现故障,如硬盘掉线、阵列卡损坏、意外断电等。收集信息:记录服务器型号、RAID配置、硬盘序列号等关键......
  • 戴尔服务器维修数据恢复
    一、确定故障类型:明确数据丢失或服务器故障的具体原因,如硬盘掉线、阵列卡损坏、意外断电等。常见故障现象包括磁盘阵列信息丢失、硬盘掉线、阵列项里不认硬盘等。保护现场:切记勿对服务器硬盘进行调换顺序、强制上线、重组等危险操作,以免对原有数据造成二次破坏。收集信息:记......
  • 服务器中病毒了,哪位安全方面的大神来给看看,急!急!急!
    这是一段病毒脚本,哪位大神给解读下,要怎么清理掉它呢?现在是文件删不掉,进程杀不掉#!/bin/sh{pkill-fxmrig||kill-9$(pgrep-f'xmrig');}>/dev/null2>&1ps-eopid,%cpu,comm--sort=-%cpu|awk'NR>1&&!/awk|ps/&&!($3~/^(logrotate|sshd|jav......
  • linux安装docker
    以下命令均以root权限执行卸载docker旧版本yumremovedockerdocker-clientdocker-client-latestdocker-commondocker-latestdocker-latest-logrotatedocker-logrotatedocker-selinuxdocker-engine-selinuxdocker-engine安装相关工具类yuminstall-yyum-utilsdev......
  • Linux多进程和多线程(一)-进程的概念和创建
    进程进程的概念进程的特点如下进程和程序的区别LINUX进程管理getpid()getppid()进程的地址空间虚拟地址和物理地址进程状态管理进程相关命令pstoppstreekill进程的创建并发和并行fork()父子进程执行不同的任务创建多个进程进程的退出exit()和_exit()exit()函数......
  • 使用EF 连接 数据库 SQLserver、MySql 实现 CodeFirst
    1.新建项目,下载Nuget安装包创建项目需要注意几点,如果是基于.netframework的项目需要选择相应版本的EF,如果是跨平台则选择EFCore版本。我这里选择的是.netframework版本。红框里面是实现EFCodeFirst需要的包。对应的版本:EntityFramework6.3.0MySql.Data6.8......
  • Linux:文件系统与日志分析
    一、block与inode1.1、概述文件是存储在硬盘上的,硬盘的最小存储单位叫做“扇区”(sector),每个扇区存储512字节。一般连续八个扇区组成一个"块”(block),一个块是4K大小,是文件存取的最小单位。文件数据包括实际数据与元信息(类似文件属性)。文件数据存储在“块"中,存储文件元......
  • 丝滑解决ImportError: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_
    基础环境:MacOSm1、python=3.9前情提要:在Anaconda终端运行代码的时候,显示报错:importError:/usr/lib/x86_64-linux-gnu/libstdc++.so.6:version`GLIBCXX_3.4.29'notfound1问题分析:根据提示是/usr/lib/x86_64-linux-gnu/路径下的libstdc++.so.6缺少版本GLIBCXX_3.4.29解......
  • Linux安装jdk
    Linux安装jdk一、下载JDKhttps://www.oracle.com/java/technologies/downloads/#java17​​上传到服务器并解压缩​​二、修改配置文件vim/etc/profile##在末尾处添加exportJAVA_HOME=/usr/local/jdk/jdk-17.0.11exportPATH=$PATH:$JAVA_HOME/bin;exportCLASSPAT......