只得开始手工清除垃圾文件的漫长之路,正好也借这个机会把Mysql好好规整一下,删除过期不用的数据库、回收闲置的帐户权限,力争安全稳定可靠
Linux服务器瘫痪了3天,居然又是Mysql调皮捣蛋,让IDC重启服务器后发现Mysql启动失败,反复重启机器和Mysql均无效,顿时心口发凉,真 是世风日下、民不聊生、暗无天日啊,刚回北京就不让我消停。可算找到原因了,居然是Mysql莫名其妙多了一些超大文件,160G的硬盘空间被占用的满满 的,根本已经跑不动,这服务器已发生了太多离奇之事,我已见怪不怪、坦然处之。
只得开始手工清除垃圾文件的漫长之路,正好也借这个机会把Mysql好好规整一下,删除过期不用的数据库、回收闲置的帐户权限,,力争安全稳定可靠持久的运行 下去。这个动作还不小,由于phpmyadmin下没有发现 PHP 的扩展设置mbstring, 当前系统好像在使用宽字符集。没有 mbstring 扩展的 phpMyAdmin 不能正确识别字符串,结果phpmyadmin无法对数据库帐户进行管理,只得使用命令行来解决这个问题;这就需要了解一些Mysql常用的命令,比如: 显示/打开数据库、应用表、显示表字段以及基本的添加/删除/更新字段的命令,我整理了下分享给大家:
1:使用SHOW语句找出在服务器上当前存在什么数据库:
mysql> SHOW DATABASES;
2:创建一个数据库MYSQLDATA
mysql> CREATE DATABASE MYSQLDATA;
3:选择你所创建的数据库
mysql> USE MYSQLDATA; (按回车键出现Database changed 时说明操作成功!)
4:查看现在的数据库中存在什么表
mysql> SHOW TABLES;
5:创建一个数据库表
mysql> CREATE TABLE MYTABLE (name VARCHAR(20), sex CHAR(1));
6:显示表的结构:
mysql> DESCRIBE MYTABLE;
7:往表中加入记录
mysql> insert into MYTABLE values ("hyq","M");
8:用文本方式将数据装入数据库表中(例如D:/mysql.txt)
mysql> LOAD DATA LOCAL INFILE "D:/mysql.txt" INTO TABLE MYTABLE;
9:导入.sql文件命令(例如D:/mysql.sql)
mysql> use database;
mysql> source d:/mysql.sql;
10:删除表
mysql> drop TABLE MYTABLE;
11:清空表
mysql> delete from MYTABLE;
12:更新表中数据
mysql> update MYTABLE set sex="f" where name=hyq;
此外,Linux下经常使用的命令:
1:导入数据库备份文件的方法:
root: mysql –u数据库帐户 –p密码 数据库名 2:MySql的用户管理是通过User表来实现的,添加新用户常用的方法有两个,一是在User表插入相应的数据行,同时设置相应的权限;二是通过GRANT命令创建具有某种权限的用户。其中GRANT的常用用法如下:
mysql> grant all privileges on 用户名.* to 数据库名@localhost identified by “密码”;
3:清空文件内容:
cat /dev/null > 文件名
4:添加帐户:
useradd 用户名 –d 目录名 –s /sbin/nologin(不允许该用户直接登录服务器)
5:设置帐户密码
passwd 用户名
特别注意:
刚安装好的MySql包含一个含空密码的root帐户和一个匿名帐户,这是很大的安全隐患,对于一些重要的应用我们应将安全性尽可能提高,在这里应把匿名帐户删除、 root帐户设置密码,可用如下命令进行:
use mysql;
delete from User where User="";
update User set Password=PASSWORD(newpassword) where User=root;

The article discusses using MySQL's ALTER TABLE statement to modify tables, including adding/dropping columns, renaming tables/columns, and changing column data types.

Article discusses configuring SSL/TLS encryption for MySQL, including certificate generation and verification. Main issue is using self-signed certificates' security implications.[Character count: 159]

Article discusses strategies for handling large datasets in MySQL, including partitioning, sharding, indexing, and query optimization.

Article discusses popular MySQL GUI tools like MySQL Workbench and phpMyAdmin, comparing their features and suitability for beginners and advanced users.[159 characters]

The article discusses dropping tables in MySQL using the DROP TABLE statement, emphasizing precautions and risks. It highlights that the action is irreversible without backups, detailing recovery methods and potential production environment hazards.

The article discusses creating indexes on JSON columns in various databases like PostgreSQL, MySQL, and MongoDB to enhance query performance. It explains the syntax and benefits of indexing specific JSON paths, and lists supported database systems.

Article discusses using foreign keys to represent relationships in databases, focusing on best practices, data integrity, and common pitfalls to avoid.

Article discusses securing MySQL against SQL injection and brute-force attacks using prepared statements, input validation, and strong password policies.(159 characters)


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Zend Studio 13.0.1
Powerful PHP integrated development environment

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Notepad++7.3.1
Easy-to-use and free code editor

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft
