Linux (CentOS 7 version) install MySQL (mariadb)

Source: Internet
Author: User

Note: In the case of CentOS 7, you can use MARIADB instead because the MySQL database has been removed from the default program list:

    • Installation commands
    • Related commands for MARIADB database
Systemctl start mariadb  #启动MariaDBsystemctl stop mariadb  #停止MariaDBsystemctl restart mariadb  # Restart Mariadbsystemctl Enable MARIADB  #设置开机启动
    • Create user
mysql> CREATE USER ' myuser ' @ ' localhost ' identified by ' mypassword ';

Once the user is created, all account details, including encrypted passwords, permissions, and resource restrictions, are stored in a table named user, which is present in the special MySQL database.

If the host is not specified (at the back of the @), all IPs can be accessed;

    • Verify that the account is created successfully by running the following command
SELECT host, user, password from mysql.user WHERE user= ' myuser ';
    • Give MySQL user permissions

A new MySQL user does not have any access rights, which means that you cannot do anything in the MySQL database. You have to give the user the necessary privileges. The following are some of the available permissions:

All: All available permissions Create: Creates libraries, tables, and indexes Lock_tables: Lock table alter: Modify table Delete: Delete Table insert: Insert table or column select: Retrieve data for table or column Create_view: CREATE VIEW Show_ DATABASES: List database drop: Delete libraries, tables, and views
    • Run the following command to give the "myuser" user specific permissions.
GRANT <privileges> on <database>.<table> to ' myuser ' @ ' localhost ';

The,<privileges> in the above command represents a comma-delimited list of permissions. If you want to assign permissions to any database (or table), use an asterisk (*) instead of the name of the database (or table).

    • Verify full permissions given to the user:

SHOW GRANTS for ' myuser ' @ ' localhost ';
    • Give all the permissions to all databases/tables:
GRANT all on * * to ' myuser ' @ ' localhost ';
    • Use the following command to revoke the existing permissions for the "MyUser" account:

REVOKE <privileges> on <database>.<table> from ' myuser ' @ ' localhost ';
    • One final important step in creating and setting up a MySQL User:

FLUSH privileges;

  

Linux (CentOS 7 version) install MySQL (mariadb)

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.