MySQL Learning notes

Source: Internet
Author: User

Installation
yum install mysqlyum install mysql-serveryum install mysql-devel
Start and stop
service mysqld startps -ef | grep mysqld[email protected]# cd /usr/bin./mysqladmin -u root -p shutdownEnter password: ******
Change root password
mysqladmin -u root password "new_password";[[email protected]]# mysql -u root -pEnter password:*******
Create user

. Method 1: Add a new user to the user table in the MySQL database

[email protected]# mysql -u root -pEnter password:*******mysql> use mysql;Database changedmysql> INSERT INTO user           (host, user, password,            select_priv, insert_priv, update_priv)            VALUES (‘localhost‘, ‘guest‘,            PASSWORD(‘guest123‘), ‘Y‘, ‘Y‘, ‘Y‘);Query OK, 1 row affected (0.20 sec)mysql> FLUSH PRIVILEGES;

. Method 2: Pass SQL to the GRANT command

mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP    -> ON TUTORIALS.*    -> TO ‘zara‘@‘localhost‘    -> IDENTIFIED BY ‘zara123‘;
Common commands

. Show databases
. Use database name
. Show tables
. Show columns from table name
. Show index from table name
. SHOW TABLE STATUS like [from db_name] [like ' pattern '] \g: This command will output the performance and statistics of the MySQL database management system.
. Show grants; View current user (Own) permissions:
. Show grants for [email protected]; To view additional MySQL user rights:
. Grant all on . to [email protected]; empowering
. Revoke all in . from [email protected]; revoke permissions
. Grant SELECT on testdb.* to [e-mail protected] with GRANT option; If you want to allow authorized users, you can also grant these permissions to other users, you need the option grant option

MySQL Learning notes

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.