Summary of common MySQL commands

Summary of common MySQL commands

Set change mysqlroot password

Enter the MySQL database for the first time.

!

You can add the absolute path of mysql to the environment variable.


You can also set the boot load.


Reload the environment variables to make MySQL take effect


Re-login to mysql -uroot

Add a password to mysql


Re-login to verify,


Change Password


Re-login verification, verification successful


Reset password, modify configuration file, skip authorization


Restart the mysql service and use the root user to authenticate without a password


Go in and modify the password file

update user set password=password('aminglinux') where user='root';

Modify my.conf after exiting

Delete the skip authorization file above

Restart the mysqld service

Re-enter mysql verification

Connect to mysql

Method 1: Use tcpip protocol ip:port, which is suitable for remote ip. This example is for local experiment.


Method 2: Use socket (assuming sock is configured in my.conf). This method is only suitable for use on the local machine.


Method 3: Use the command line, suitable for shell scripts

Common mysql commands

Query library show databases;

Switch library to use mysql;

View the tables in the library show tables;


View the field desc tb_name in the table ;


View the table creation statement show create table tb_name\G;


View the current user select user ();


View the currently used database select databsase();

Create database create database db1;


Create table use db1; create table t1( id int(4), name char(40)) ENGINE=InnoDB DEFAULT CHARSET=utf8;


Delete table drop table t1;

View the current database version select version ();


Check the database status show status ;


View each parameter show variables; wildcard show variables like 'max_connect%';


Modify the parameter set global max_connect_errors=1000; you can also modify it in /etc/my.conf


View the queue show processlist; show full processlist;

You may also be interested in:
  • A collection of commonly used MySQL commands [absolutely essential]
  • mysql cmd common commands
  • Summary of MySQL import and export .sql files and common commands
  • MySQL common commands
  • Summary of common commands for MySQL database backup and restore
  • Common command line statements for mysql
  • Detailed version of commonly used MySQL commands
  • A beginner's guide to common commands for operating MySQL databases and tables
  • Summary of commonly used mysql commands 123WORDPRESS.COM version
  • Summary of common commands for viewing and clearing MySQL tables
  • Common commands for mysql maintenance

<<:  Vue application example code based on axios request encapsulation

>>:  How to install Docker on Windows Server 2016

Recommend

Installation tutorial of mysql8.0rpm on centos7

First, download the diagram 1. First uninstall th...

Summary of several error logs about MySQL MHA setup and switching

1: masterha_check_repl replica set error replicat...

How to deploy nodejs service using Dockerfile

Initialize Dockerfile Assuming our project is nam...

HTTP return code list (Chinese and English explanation)

http return code list (below is an overview) for ...

Talking about the practical application of html mailto (email)

As we all know, mailto is a very practical HTML ta...

How to install and configure MySQL and change the root password

1. Installation apt-get install mysql-server requ...

Example code of CSS responsive layout system

Responsive layout systems are already very common...

Introduction to HTML link anchor tags and their role in SEO

The <a> tag is mainly used to define links ...

Introduction to the use of alt and title attributes of HTML img tags

When browser vendors bend the standards and take i...

How to allow external network access to mysql and modify mysql account password

The root account of mysql, I usually use localhos...

MySQL 5.7 installation and configuration tutorial

This article shares the MySQL installation and co...

Several specific methods of Mysql space cleaning

Table of contents Preface 1. Check the file disk ...

MySQL database constraints and data table design principles

Table of contents 1. Database constraints 1.1 Int...

The marquee element implements effects such as scrolling fonts and pictures

The marquee element can achieve simple font (image...