MySQL (mariadb)
==========
Yum Install Mariadb-server
Mysqladmin-uroot-predhat Password Westos # Modify the local mysql root password
mysqladmin-uroot-predhat-h 192.168.0.188 Password Westos # modify remote 192.168.0.188 MySQL server root password
Mysql_secure_installation # After installing MySQL for the first time , MySQL can be set by this command
Configuration
Adding and removing Change to check *******
Mysql-uroot-predhat # Log in to MySQL database from native computer
show databases; #显示数据库
Use MySQL; #进入数据库
Show tables; #显示数据库中的表
DESC user; # View data structure of user table
Flush privileges; #刷新数据库信息
Select Host.user,password from user; # Querying the Host,user,password field in the user table
SELECT * from Mysql.user; # query All of the user tables in the MySQL library
Create Database Westos; # Create a Westos database
Use Westos;
CREATE TABLE Linux (#创建表, Username,password field
Username varchar () NOT NULL,
#字符长度 #不可为空
Password varchar () NOT NULL
);
INSERT into Linux values (' User1 ', ' passwd1 '); #在linux表中插入值为username = User1,password = Password1
Update Linux set Password=password (' Passwd2 ') where username=user1; The password for the #更新linux表中user1 is Password2
Delete from Linux where username=user1; #删除linux表中user1的所以内容
ALTER TABLE Linux Add age varchar (4) Before password # add field after Name field age
ALTER TABLE Linux Drop Age # Delete age field
User Rights Management ******
Grant SELECT On * * to [e-mail protected] identified by ' PASSWD1 '; authorization wesots password for passwd1 #并且只能在本地 querying the database so content
REVOKE SELECT on * * FROM [email protected]
Grant all on mysql.* to [email protected] '% ' identified by ' passwd2 '; authorization user2 password is PASSWD2 #可以从远程任意主机登录mysql and can operate on MySQL database arbitrarily
Backup *******
/var/lib/mysql
Mysqldump-uroot-predhat mysql > Mysql.bak # back up MySQL library to Mysql.bak
Mysql-uroot-predhat Westos < Mysql.bak # recover Mysql.bak to Westos Library
MySQL Password recovery ******
Systemctl Stop mariadb #关闭mysql
Mysqld_safe--skip-grant-tables & # Skip grant-tables Authorization table does not require authentication login to the local MySQL database
Update Mysql.user set Password=password (' Westos ') where user= ' root ';
# Update mysql.user The password for the root user in the table is encrypted Westos
Systemctl Restart MARIADB #重启mysql
MySQL (mariadb)