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