The purpose of this experiment is to build MySQL server
First, pre-preparatory work
1. Prepare a rhel7.2 host
2. Download RPM Package: wget Https://dev.mysql.com/downloads/mysql/mysql-5.7.17-1.el7.x86_64.rpm-bundle.tar
3, uninstall the system MARIADB database
Search: Rpm-qa | grep mariadb-server
If there is one, uninstall: yum-y Remove Mariadb-server mariadb
Second, installation
1, decompression: TAR-XF Mysql-5.7.17-1.el7.x86_64.rpm-bundle.tar
2. Remove the minimum installed RPM package:
RM-RF mysql-community-server-minimal-5.7.17-1.el7.x86_64.rpm
3. Install the dependent package:
Yum-y Install Perl-data-dumper Perl-json perl-time-hires
4, install the database,-U is the upgrade installation
RPM-UVH mysql-community-*.rpm
5, restart the service, boot from the service
Systemctl restart mysqld; Systemctl enable mysqld;
6. Viewing and verifying
Check to see if it starts: Ps-aux | grep 3306 netstat-ntulp | grep 3306
Data file storage:/var/lib/mysql
Path of the configuration file:/etc/my.cnf
Initial log path:/var/log/mysqld.log
Third, the initial password modification process
Due to the MYSQL5.7RPM installation process, an original password is generated and must be modified before it can be used
So here is the process of changing the password:
1. Modify the configuration file:
validate_password_policy=0//0 is the cancellation of the password complexity, the default is 1
validate_password_length=6//Minimum password length is 6
2. Restart the database service: Systemctl restart Mysqld
3. Check the original password:
grep ' temporary password '/var/log/mysqld.log
Get: [email protected]: l) vfhq1zsto>
4. Login with original password: Mysql-uroot-p ' L) vfhq1zsto> '
-U specify user,-p specify password
5, modify the original password: set Password=password ("123456");
6, exit, and then use the newly changed password to verify the login.
Iv. Some basic operations of the database:
1, library-related operations:
Select Database (); Confirm the current library
Create Database Bbsdb; Create a database
Use MySQL; Switch database
Drop database Bbsdb; Delete a library
2, the table related to some basic operations:
CREATE TABLE Stuinfo (name char), sex char (5), Class char (8)); Create a table
INSERT into Stuinfo values ("Tom", "Boy", "123"); Inserting data into a table
Update stuinfo set name= "hehe" where sex= "Reny"; Updating data in tables
Desc Stuinfo; View table Structure
Delete from Stuinfo; Delete all content in a table
drop table stuinfo; Delete a table
3, modify the table structure of the operation:
add field: ALTER TABLE name add field name type constraint first after (field name);
Delete field: ALTER TABLE name drop field name;
Modify field type: ALTER TABLE name modify field name type constraint;
Modify field name: ALTER TABLE name change Source field name new field name type constraint condition;
Modify table name: ALTER TABLE source table name rename new table name;
MySQL Series 1---mysql server build