The basic operation of the installation and mysql

System environment:

CentOS Linux release 7.6.1810 (Core)

mysql Version: 5.27 Download https://dev.mysql.com/downloads/mysql/
[root @ Server10 mysql7] # # LS download the installation package and install
mysql-community-client-5.7.25-1.el7.x86_64. RPM
MySQL-Community-Common-5.7.25-1.el7.x86_64.rpm
MySQL-Community-libs-5.7.25-1.el7.x86_64.rpm
MySQL-Community-libs-compat-5.7.25-1.el7 // the Test .x86_64.rpm
MySQL-Community Community-Server-5.7.25-1.el7.x86_64.rpm
[root @ Server10 mysql7] # yum install *
[root @ Server10 ~] # systemctl Start mysqld
[root @ Server10 MySQL] # grep password /var/log/mysqld.log # View original password

[root @ server10 mysql7] # ls # download the package and install the
MySQL-Community-Client-5.7.25-1.el7.x86_64.rpm
MySQL-Community-Common-5.7.25-1.el7.x86_64.rpm
MySQL- 5.7.25-1.el7.x86_64.rpm-libs-Community Community
MySQL-Community Community-libs-compat-5.7.25-1.el7.x86_64.rpm the Test //
MySQL-Community Community-Server-5.7.25-1.el7 .x86_64.rpm
[root @ Server10 mysql7] # yum install *
[root @ Server10 ~] # systemctl Start mysqld
[root @ Server10 MySQL] # grep password /var/log/mysqld.log # View original password

[Root @ server10 mysql] # mysql_secure_installation # # initialize change the root password is case-sensitive password with special characters not less than eight and then all the way round

[root@server10 mysql]# mysql -p

mysql> show databases; # View Gallery

+--------------------+

| Database |

+--------------------+

| information_schema |

| mysql |

| performance_schema |

| sys |

+--------------------+

4 rows in set (0.00 sec)

mysql> create database westos; #建库

Query OK, 1 row affected (0.00 sec)

mysql> use westos;

Database changed

mysql> create table linux( #建表

-> user varchar(20) not null,

-> password varchar(20) not null

-> );

Query OK, 0 rows affected (0.01 sec)

mysql> desc linux; # View table structure

+----------+-------------+------+-----+---------+-------+

| Field | Type | Null | Key | Default | Extra |

+----------+-------------+------+-----+---------+-------+

| user | varchar(20) | NO | | NULL | |

| password | varchar(20) | NO | | NULL | |

+----------+-------------+------+-----+---------+-------+

2 rows in set (0.00 sec)

mysql> insert into linux values ​​( 'wo', '134'); # insert data

Query OK, 1 row affected (0.00 sec

mysql> select * from linux; # View table

+------+----------+

| user | password |

+------+----------+

| where | 134 |

+------+----------+

1 row in set (0.00 sec
user authorization:

mysql> create user guoyanfeng @ '% ' identified by '[email protected]'; # create a user
Query OK, 0 rows affected (0.00 sec)

mysql> grant select, insert on westos * to guoyanfeng @ '%';. # Authorization to the library
Query OK, 0 rows affected (0.00 sec)

mysql> show grants for guoyanfeng @ '%'; # View permissions

+--------------------------------------------------------+

| Grants for guoyanfeng @% |

+--------------------------------------------------------+

| GRANT USAGE ON . TO 'guoyanfeng'@'%' |

| GRANT SELECT, INSERT ON westos.* TO 'guoyanfeng'@'%' |

+--------------------------------------------------------+

2 rows in set (0.00 sec)

MySQL> Grant All privileges ON . to guoyanfeng @ '%'; full permissions to all library users #

mysql> revoke insert, select on westos * from guoyanfeng @ '%';. # revoke privileges

mysql> show grants for guoyanfeng@'%';

+-------------------------------------------------+

| Grants for guoyanfeng @% |

+-------------------------------------------------+

| GRANT ALL PRIVILEGES ON . TO 'guoyanfeng'@'%' |

+-------------------------------------------------+

mysql> use mysql;

mysql> update mysql.user set authentication_string=password('XR&westos123.com') where user='guoyanfeng' #改用户密码

mysql> flush privileges; # refresh

mysqldump -uroot -pwestos - all-databases ## backups of all databases

mysqldump -uroot -pwestos --all-database - no-data ## to backup all databases frame

[root@server10 ~]# mysqldump -u root -pCaonimei@478 --all-databases > /mnt/all.sql

mysqldump: [Warning] Using a password on the command line interface can be insecure # backup will get an error but does not affect the backup, the reason for the mysql version of the problem must add a user name and password in the my.cnf file to perform a backup.
mysql skip the login password:

1. Add skip-grant-tables in the etc / my.cnf the [mysqld]

2. Restart the mysql service can be.
When mysql encountered unsolvable problem: # caution

Back up all databases to determine and correct.

[Root @ server10 mysql] # systemctl stop mysqld.service # stop database

[Root @ server10 mysql] # cd / var / lib / mysql # default path

[Root @ server10 mysql] # rm -fr * # Delete all, re-initialization

Guess you like

Origin blog.51cto.com/13810716/2427782