MySQL Daily operations Basics

Source: Internet
Author: User

One. Database version:
Community Edition Enterprise Edition Cluster edition
Community Edition: Free to use (can be used for personal use, no commercial use)
Enterprise Edition: Less expensive than the cluster edition
Cluster version:

Official website: http://www.mysql.org

Two. mysql installation (MySQL Toolkit mysql-server module and Feature Pack)
#yum-y install MySQL mysql-server # #yum installation
Default port: 3306

650) this.width=650; "title=" installation. png "src=" https://s2.51cto.com/wyfs02/M02/8F/3C/ Wkiol1jyhhracs9haaayoj0nkxu592.png-wh_500x0-wm_3-wmp_4-s_2449096838.png "alt=" Wkiol1jyhhracs9haaayoj0nkxu592.png-wh_50 "/>


650) this.width=650; "title=" port. png "src=" https://s3.51cto.com/wyfs02/M01/8F/3C/ Wkiol1jyhmcbgvgeaaarun-quze039.png-wh_500x0-wm_3-wmp_4-s_1772197005.png "alt=" Wkiol1jyhmcbgvgeaaarun-quze039.png-wh_50 "/>




Master configuration file:/etc/my.cnf
#ps aux | grep mysqld # # View service-related module information


650) this.width=650; "title=" module information. png "src=" https://s1.51cto.com/wyfs02/M01/8F/3C/ Wkiol1jyhr6rs51naaav1lys25c636.png-wh_500x0-wm_3-wmp_4-s_2499193962.png "alt=" Wkiol1jyhr6rs51naaav1lys25c636.png-wh_50 "/>


Important parameters

--datadir=/var/lib/mysql (Data Catalog)
--socket=/var/lib/mysql/mysql.socket (socket file directory)
--basedir=/usr/installation directory
--user= Process Run user identity
--log-error=/var/log/mysqld.log specifying the database error log directory



#cd/var/lib/mysql
#ls (MySQL)

650) this.width=650; "title=" Mysql.png "src=" https://s1.51cto.com/wyfs02/M01/8F/3C/ Wkiol1jyifsrht6jaaapbydj5pc766.png-wh_500x0-wm_3-wmp_4-s_4235567625.png "alt=" Wkiol1jyifsrht6jaaapbydj5pc766.png-wh_50 "/>



MySQL (data sheet file) ib_lngfilel (index file) mysql.sock
#cd./mysql
--datadir Data Catalog
Storing database related information
. frm data table structure
Data for the. MYD Data Sheet
. myi Data Table Index file
Mysql.sock Database Socket file




MySQL Login
-U login Name
-p password
-H Specify the MySQL server address
-P Port


650) this.width=650; "title=" Log in to the MySQL database locally. png "src=" https://s2.51cto.com/wyfs02/M00/8F/3E/ Wkiom1jyiltzk17uaaafirtv0fm131.png-wh_500x0-wm_3-wmp_4-s_2225567109.png "alt=" Wkiom1jyiltzk17uaaafirtv0fm131.png-wh_50 "/>






Set the password for the database administrator mysqladmin
#mysqladmin-uroot password ' 123 '; # #添加初始密


#mysql-uroot-p # #登录mysql


mysql>create user [email protected] ' localhost ' identified by
' 123 '; # #创建lisi用户本地登录mysql

650) this.width=650; "title=" 1.png "src=" https://s4.51cto.com/wyfs02/M01/8F/3C/wKioL1jYjFqQnwiMAAAOoT_ 39yo299.png-wh_500x0-wm_3-wmp_4-s_1582331181.png "alt=" Wkiol1jyjfqqnwimaaaoot_39yo299.png-wh_50 "/>



mysql>create user [email protected] '% ' identified by ' 123 '; # #创建张三用户可以在任何远端地址远程登录mysql


650) this.width=650; "title=" 2.png "src=" https://s4.51cto.com/wyfs02/M02/8F/3E/wKiom1jYjJ3hmLrKAAARynXCH_ M076.png-wh_500x0-wm_3-wmp_4-s_497803130.png "alt=" Wkiom1jyjj3hmlrkaaarynxch_m076.png-wh_50 "/>




Mysql>set password for ' user ' @ ' login address ' =password ("New password");

650) this.width=650; "title=" 3.png "src=" https://s1.51cto.com/wyfs02/M02/8F/3E/ Wkiom1jyjpvhbyiwaaamvojcs04870.png-wh_500x0-wm_3-wmp_4-s_3335806395.png "alt=" Wkiom1jyjpvhbyiwaaamvojcs04870.png-wh_50 "/>






Forget the database Password resolution method:
1. Stop the database


650) this.width=650; "title=" Stop.png "src=" https://s3.51cto.com/wyfs02/M01/8F/3E/ Wkiom1jyibstci4vaaaok4rgyly740.png-wh_500x0-wm_3-wmp_4-s_2139982398.png "alt=" Wkiom1jyibstci4vaaaok4rgyly740.png-wh_50 "/>


2. Modify the Master profile to add one line of code: Skip-grant-tables




650) this.width=650; "title=" Skip.png "src=" https://s5.51cto.com/wyfs02/M00/8F/3C/ Wkiol1jyiyldboi5aaaluvhscw0464.png-wh_500x0-wm_3-wmp_4-s_2082681253.png "alt=" Wkiol1jyiyldboi5aaaluvhscw0464.png-wh_50 "/>



3. Restart the service
4. Reset Password
Mysql>set password=password (' New password '); # #更改管理员数据库用户密码
This time will be error because skipped the grant authentication table, you need to update the database user data table Mysql>update mysql.user set Password=password (' New password ') where user= ' root ';


650) this.width=650; "title=" Unnamed.png "src=" https://s4.51cto.com/wyfs02/M02/8F/3C/ Wkiol1jyiw-dizl-aaasnpxryis194.png-wh_500x0-wm_3-wmp_4-s_663747623.png "alt=" Wkiol1jyiw-dizl-aaasnpxryis194.png-wh_50 "/>







Display Database
>show databases;
Show content under a specific database
>use test;


>create Table A2 (
ID int unsigned NOT NULL auto_increment,
Name Char (+) NOT NULL default "",
Info char (208) NULL,
Primary key (ID));

Id
Name
Info



































































This article from the "12134803" blog, reproduced please contact the author!

MySQL Daily operations Basics

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.