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
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
Recommended Posts