mysql installation and command

1. First check whether the system is equipped with mysql

rpm -qa | grep mysql

2. Download the repo source mysql

wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm

3. Install mysql-community-release-el7-5.noarch.rpm package

rpm -ivh mysql-community-release-el7-5.noarch.rpm

4. Install MySQL

yum -y install mysql

5. Reset MySQL password

Mysql command-line input directly into the database

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

exit exit

6. Restart the MySQL service

systemctl restart mysql 

Re-enter the input mysql -uroot -p123456

 

The basic command mysql

show databases; view the database

use mysql; switch databases

sleect database (); view the current database

show tables Table View Curry

desc name.node; see table structure

select * from name.node view the name of the node table data library

create database name character set utf8mb4; create database character name support Chinese character set specified utf8mb4

create table name.node (id int (10), dc char (20)); create the table structure

insert into name.node values ​​(1, "zhangsan"); add data to a node table

update name.node set id = 1 where dc = "zhangsan" id changed to meet the conditions of data such as the conditions change without the entire data list

drop database name; delete database name

delete from name.node where id = 1; delete satisfies the conditions where the data without such a table where all the data is deleted

drop table name.node; delete the entire table

 

 

Guess you like

Origin www.cnblogs.com/xiaolei123/p/11873095.html