Mysql user creation and mysql Creation

Source: Internet
Author: User
Tags mysql commands

Mysql user creation and mysql Creation

Mysql commands are case insensitive. Content and table names are case sensitive.

The statement ends. (\ C) do not want to execute the command being entered. (Command + \ G;) view detailed structure

Start/stop/restart:Server mysql start/stop/restart

/Etc/init. d/mysql start/stop/restart

Systemctl start/stop/restart mysql

1. Add an account

1. The general account is in the mysql. user table. Use insert into... values... to add it to the table. If Column count doesn't match value count at row 1 is incorrect. View Field matching with describe user

2. create user 'username' @ 'host (localhost/% [any host]) 'identified by 'Password ';

Ii. Authorization

Grant (all/select, insert, and other restriction commands) on (*. */databasename. tablename and other database names and table names) to 'brandchen '@ 'localhost' (the created user name/host). + with grant option has the permission to authorize other users 」; % "indicates authorization to all non-local hosts, excluding localhost

Revoke (all/select, insert, and other restrictions) on (*. */databasename. tablename and other database names, table names) from 'username' @ 'hostname'; revoke permissions

Flush privileges; // refresh the system permission list

  show grants for 'username'@'hostname';View the user's available permissions.

3. Password Modification

Set password for 'username' @ 'hostname' = password ('...');

Or use update user set password = password ('... ') where User = "... "and Host = "... "; (modify the table content)

Flush privileges;

4. delete a user

  drop user 'username'@'hostname';
  flush privileges;

5. forgot password

1. kill the mysql process: ps-aux | grep mysql

2. mysqld_safe -- skip-grant-table & skip Password Authentication

3. mysql-u root

4. Change the password, refresh, and restart the system.

Related Article

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.