Installation (based on CentOS)
Yum-y Install mariadb mariadb-server # centos7 version #centos7 The following versions
Start
Service mysqld start # centos7 The following version Chkconfig mysqld on # set power on start orsystemctl start mariadb # centos7systemctl enable mariadb
Set Password
1 '1234'# Modify the root user password 2. Go to MySQL library Modify user table MySQL> Use MySQL MySQL>update user set Password=password (' your password ') where user=' Root'; MySQL
Login
MySQL # Local login, Default user root, blank password, user for [email protected]# Local login, specify user name and password, user is [email Protected]# telnet, user is [email protected]
Common commands for MySQL
-- --to start the MySQL service with the Stop MySQL service command:-- --net start MySQL--net stop MySQL-- -- --Login and Exit commands:----Mysql-h server ip-p port number-u user name-p password--prompt command prompt--delimiter specify delimiter--Mysql-h 127.0.0.1-p 3306-uroot-p123--Quit------Exit----\q;------\s; ------My.ini file: [MySQL] default-character-set=gbk [mysqld] character-set-server=GBK-- --prompt Command Prompt (\d: current date \d: Current database \u: Current user)-- --\ t (start log) \ t (end log)-- --show warnings;-- --Help ()? \h-- --\g;-- --Select Now ();--select version ();--Select User;-- --\c Cancel Command----delimiter specifying delimiters
Forgot password
method One: Skip the Authorization form when you start MySQL [email protected]~]#Service mysqld Stop[[Email protected] ~]#mysqld_safe--skip-grant-table &[[Email protected] ~]#MySQLMysql> Select User,host,password fromMysql.user;+----------+-----------------------+-------------------------------------------+| user | Host | Password |+----------+-----------------------+------------------------------------------- +| Root | localhost | *A4B6157319038724E3560894F7F932C8886EBFCF | | Root | Localhost.localdomain | || Root | 127.0.0.1 | || Root | :: 1 | || | localhost | || | Localhost.localdomain | || Root | % | *23ae809ddacaf96af0fd78ed04b6a265e05aa257 |+----------+-----------------------+--------------------------------- ----------+MySQL> Update Mysql.user Set Password=password ("123") Where user="Root" andhost="localhost"; MySQL>Flush Privileges;mysql>Exit[[email protected]~]#Service mysqld Restart[[Email protected] ~]#mysql-uroot-p123
SQL and its specifications
<1> in a database system, SQL statements are case-insensitive (uppercase is recommended). However, string constants are case-sensitive. Recommended command uppercase, table name Library name lowercase;<2> SQL statements can be written in single or multiple lines, with ";" End. Keywords cannot span multiple lines or abbreviations. <3> use spaces and indents to improve the readability of the statement. Clauses are usually located on separate lines, making editing easier and more readable. * FROM tb_table WHERE NAME="YUAN"; <4> Note: Single line comment:-- Multiline Comment:/*......*/<5>sql statement can be wrapped
MySQL Database operations
Basic operation of MySQL database