Installation and use of Mysql under CentOS

1. Use the installation command: yum -y install mysql mysql-server mysql-devel

The installation is complete, but the Myserver installation is missing. I found the reason on the Internet. It turned out that MySQL was removed from the default software list on CentOS 7 and replaced with MariaDB, so we have to go to the official website. Download, find the link, open with wget:

a: #wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm

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

c. Perform yum -y install mysql mysql-server mysql-devel twice, and the installation is successful. Use the command again and get the following information

2. Mysql is divided into two ports, client and server. If you want to use it, first open the server

3. Next enter the client, use the command mysql -u root -p to enter the password, the default is empty

4. Basic operations show databases;

5. Use a database use chouti, view the table show tables;

6. Common database operations

1 mysql database usage summary
 2 This article mainly records some of the commands used daily by mysql for later query.
 31. Change root password
 4 mysqladmin -uroot password 'yourpassword'52.Remote login to mysql server
 6 mysql -uroot -p -h192.168.137.10-P3306
 73. Query database
 8 show databases;94.Enter a database
10 use databasename;115.List the tables in the database
12 show tables;136.View all fields in a table
14 desc slow_log;15 show create table slow_log\G;(It can display not only table information, but also table building statement)
167. View current user
17 select user();188.View the current database
19 select database();209.Create a new database (character set can be specified)
21 create database db1 charset utf8;2210.Create new table
23 create table t1(`id`int(4),`name`char(40));2411.View database version
25 select version();2612.View database status
27 show status;Current session state
28 show global status;Global database status
29 show slave status\G;View master-slave database status information
3013. Query database parameters
31 show variables;3214.Modify database parameters
33 show variables like 'max_connect%';34set global max_connect_errors =1000;(Restart the database will be invalid, to be modified in the configuration file)
3515. View the current database queue
36 show processlist;3716.Create ordinary users and authorize to a database
38 grant all on databasename.* to 'user1'@'localhost' identified by '123456';3917.Query table data
40 select *from mysql.db;//Query all fields in the table 41 select count(*)from mysql.user;//count(*)Indicates how many rows are in the table 42 select db,user  from mysql.db;//Query multiple fields in the table 43 select*from mysql.db where host like '10.0.%';Universal matching can be used in the query statement "%”
4418. Insert a row of data
45 insert into db1.t1 values(1,'abc');4619.Change a row of data in the table
47 update db1.t1 set name='aaa' where id=1;4820.Clear table data
49 truncate table db1.t1;5021.Delete table
51 drop table db1.t1;5222.Clear all tables in the database (database name is eab12)
53 mysql -N -s information_schema -e "SELECT CONCAT('TRUNCATE TABLE ',TABLE_NAME,';') FROM TABLES WHERE TABLE_SCHEMA='eab12'"| mysql -f eab12
5423. Delete database
55 drop database db1;5624.database backup
57 mysqldump  -uroot -p'yourpassword' mysql >/tmp/mysql.sql
5825. Database recovery
59 mysql -uroot -p'yourpassword' mysql </tmp/mysql.sql
6026. New ordinary user
61 CREATE USER name IDENTIFIED BY 'ssapdrow';6227.Change common user password
63 SET PASSWORD FOR name=PASSWORD('fdddfd');6428.View the permissions of user name
65 SHOW GRANTS FOR name;6629.Execute mysql command in script
67 mysql -uuser -ppasswd -e"show databases"68 echo "show databases"|mysql -uuser -ppassword
69 The following is the way to execute a large number of mysql statements
70 mysql -uuser -hhostname -ppasswd <<EOF
71 mysql statement
72 EOF
  1. As for the addition, deletion, and modification of the table, it is not shown here because it belongs to another content. Due to the bandwidth or space limitations of the server (CentOS), it is unlikely to perform corresponding navic-like graphical operations like windows, so please be familiar with the corresponding operations on the black screen window.

Recommended Posts

Installation and use of Mysql under CentOS
MySQL 8.0 installation, deployment and configuration under CentOS 6/7
Installation and configuration of redis under centos7
KVM installation and preliminary use under CentOS 7.2
Centos mysql installation and configuration
centos7 kvm installation and use
Installation and configuration of rsync server under CentOS 6.5
CentOS7 postgresql installation and use
MySQL 8.0 installation and deployment under CentOS, super detailed!
Centos7 elk7.1.1 installation and use
Installation and cracking of confluence6.3 operation records under Centos
Installation and cracking of Jira7 operation records under Centos
Installation and use of GDAL in Python under Ubuntu
Environment configuration of JDK, mysql and tomcat under Centos7
Use Nginx and u under CentOS
Centos6.5 installation and deployment of KVM
Installation under centos6.9 of jenkins learning
CentOS7 installation and maintenance of Gitlab
Java-JDK installation and configuration under CentOS
Install and use docker under CentOS 6.8
Erlang 20.2 installation and deployment under CentOS 7
Centos7 mysql database installation and configuration
Detailed explanation of Spark installation and configuration tutorial under centOS7
Introduction to CentOS7 installation process of openjdk, tomcat and mysql
Tomcat installation and configuration under CentOS 7 (Tomcat startup)
Centos-6.5 installation and deployment of LNMP environment
Centos7 installation and deployment of gitlab server
Installation and uninstallation of CUDA under Ubuntu 16.04
Installation and use of Win10 subsystem Ubuntu
Zabbix installation and deployment and localization under CentOS
Jenkins installation and deployment tutorial under CentOS 7
Centos7 installation and deployment of Airflow detailed
Install mysql5.7 under CentOS7
Graphical installation of CentOS8
Mysql8.0.15 installation configuration (centos7)
Install mysql under Centos 7
Redis3 installation under Centos7
Install mysql5.1 under CentOS6.5
Installation and configuration of JDK in CentOS 7 system
Installation of pulseaudio and API usage under Ubuntu 12.04
CentOS 7 installation and configuration graphic tutorials under VMware10
Centos7 installation of PHP and Nginx tutorial detailed
Installation and configuration of CentOS 7 in VMware Workstation
Modify the default encoding of mysql5.6 under CentOS7
Non-Root installation of Microsoft R Open under Centos
MySQL 8.0 installation, deployment and configuration tutorial on CentOS 8
Installation and use of SSH in Ubuntu environment
From installation to entry of FastDFS under Centos7
Redis cluster installation under CentOS
Centos7 installation and configuration prometheus
CentOS 7 installation and configuration PPTP
CentOS 6.x installation mysql5.7 record
CentOS installation and configuration cmake
Install MySQL under Linux (CentOS 7)
Centos7.5 installation and configuration MongoDB4.0.4
Redis cluster installation under CentOS
CentOS 7 installation and configuration PPTP
GitLab installation and basic use
Installation and simple practice of MySQL in ubuntu environment (1)
Centos7 silent installation of Oracle11g
Use of mediawiki under ubuntu