Mysql permission Check

Source: Internet
Author: User

Permission check

Permissions are stored in the MySQL library's user, DB, Tables_priv, Columns_priv, and PROCS_PRIV systems tables, which are loaded into memory when the MySQL instance is started.

User information is stored in the Mysql.user table. By default, only Superuser root is installed (if anonymous users are not created).

mysql> desc Mysql.user;

+------------------------+-----------------------------------+------+-----+----------

| Field | Type | Null | Key | Default

+------------------------+-----------------------------------+------+-----+----------

| Host | char (60) | NO | PRI |

| User | char (32) | NO | PRI |

Host+user the composite primary key. The client + user name that is allowed to access. So the same name is allowed.

Host:localhost//Indicates only native access and cannot be accessed remotely.

User:root

Create user

Method 1, direct root creation. Not recommended.

Method 2, which specifically creates instructions, needs to be given permissions.

Create user ' username ' @ '% ' identified with Mysql_native_password by ' password '; % means that any client access is allowed.

Create user username; Allow any client without password access.

granting permissions

Grant all privileges on * * to ' username ' @ '% '; This man becomes God. Permission details Baidu.

Modify User Password

Set password for ' username ' @ '% ' = password (' password ');

Update mysql.user Set password = password (' password ') where user = ' username ' and host = ' host ';

Delete User

Drop user ' username ' @ ' host ';

Forgot root password

C:\users\windows7-64>net stop MySQL

The MySQL service is stopping.

The MySQL service has stopped successfully.

C:\USERS\WINDOWS7-64>CD C:\Program Files (x86) \mysql\mysql Server 5.0\bin

C:\Program Files (x86) \mysql\mysql Server 5.0\bin>mysqld.exe--skip-grant-tables//Skip verification login, full access, very dangerous, you know.

C:\Program Files (x86) \mysql\mysql Server 5.0\bin>mysql

mysql> Update Mysql.user Set Password=password (' root ') where user= ' root ' and host= ' localhost ';

Query OK, 1 row affected (0.03 sec)

Rows matched:1 changed:1 warnings:0

Kill Process Mysqld.exe

C:\Program Files (x86) \mysql\mysql Server 5.0\bin>net start MySQL

The MySQL service is starting.

The MySQL service has started successfully.

C:\Program Files (x86) \mysql\mysql Server 5.0\bin>mysql-uroot-proot

Mysql>

Mysql permission Check

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.