Issues such as creating users and assigning permissions to MySQL under Linux

Source: Internet
Author: User
Tags file copy mysql client


Steps to install MySQL on a Linux system


Tools:

Mysql-5.6.17-linux-glibc2.5-i686.tar.gz

Mysql-5.6.17-linux-glibc2.5-x86_64.tar.gz

Linux System 64-bit

Method/Step

1, to the MySQL website download mysql compiled binary installation package.

2. Unpack the installation package:

3. Enter the directory where the installation package is located, execute the command: TAR-ZXVF mysql-5.6.17-linux-glibc2.5-i686.tar.gz

4. Copy the extracted MySQL directory to the local software directory of the system:

Execute command: CP mysql-5.6.17-linux-glibc2.5-i686/usr/local/mysql-r

Note: The end of the directory does not add/

5. Add System MySQL Group and MySQL User:

Execute command: Groupadd MySQL and useradd-r-g MySQL MySQL

6. Install the database:

7. Go to install MySQL software directory: Execute command cd/usr/local/mysql

8. Modify the current directory owner for MySQL User: Execute command chown-r mysql:mysql.

9, install the database: Execute the command./scripts/mysql_install_db--user=mysql

10, modify the current directory owner is the root user: Execute the command chown-r root:root.

11. Modify the current data directory owner for MySQL User: Execute command chown-r mysql:mysql data

to this database installation is complete

1. Start MySQL service and add boot MySQL service:

Add Boot: Execute command CP Support-files/mysql.server/etc/init.d/mysql, put startup script into boot initialization directory

2. Start MySQL service: Execute command service MySQL start

Execute command: ps-ef|grep mysql see MySQL service description started successfully

3. Modify the root user password of MySQL, the root initial password is empty:

Execute command:./bin/mysqladmin-u root password ' password '

4. Put the MySQL client on the default path:

Ln-s/usr/local/mysql/bin/mysql/usr/local/bin/mysql

Note: It is recommended to use the soft chain in the past, do not directly package file copy, easy to install multiple versions of MySQL system


Create a user and assign permissions to MySQL under Linux

1. Create a new user

Log in to MySQL

@>mysql-u root-p

@> Password

Create user

mysql> INSERT INTO Mysql.user (Host,user,password) VALUES (' localhost ', ' Tome ', Password (' Tome '));

Refresh System Permissions Table

Mysql>flush privileges;

This creates a user named: Tome Password: Tome.

Log in after exiting

mysql>exit;

@>mysql-u tome-p

@> Enter password

Mysql> Login Successful


2. Authorizing the user

Log in to MySQL (with root privileges). I am logged in as root.

@>mysql-u root-p

@> Password

First create a database for the user (Tomedb)

Mysql>create database tomedb;

Authorizing JEECN users to have all rights to the tome database

@>grant all privileges in tomedb.* to [email protected] identified by ' Tome ';

Refresh System Permissions Table

Mysql>flush privileges;

Mysql> Other operations

If you want to specify partial permissions to a user, you can write:

mysql>grant select,update on tomedb.* to [email protected] identified by ' Tome ';

Refreshes the System permissions table.

Mysql>flush privileges;

Mysql> grant permissions 1, permissions 2,... Permission n on the database name. Table name to User name @ user address identified by ' connection password ';

Permissions 1, Permissions 2,... Permission n represents 14 permissions, such as Select,insert,update,delete,create,drop,index,alter,grant,references,reload,shutdown,process,file.

When permissions 1, permissions 2,... Permission n is replaced by all privileges or all to give the user full permission.

When the database name. The table name is replaced by *. * to give the user permission to manipulate all tables on all databases on the server.

The user address can be localhost, or it can be an IP address, a machine name, and a domain name. You can also use '% ' to indicate connections from any address.

' Connection password ' cannot be empty, otherwise the creation failed.

For example:

mysql>grant select,insert,update,delete,create,drop on Vtdc.employee to EE @10.25.197.95 identified by ' 123′;

The user EE from 10.25.197.95 is assigned the ability to perform operations such as Select,insert,update,delete,create,drop on the employee table VTDC the database, and the password is set to 123.

mysql>grant all privileges in vtdc.* to [email protected] identified by ' 123′;

The user EE from 10.25.197.95 is assigned permission to perform all operations on the database VTDC all tables, and the password is set to 123.

mysql>grant All privileges on * * to [email protected] identified by ' 123′;

The user EE from 10.25.197.95 is assigned permission to perform all operations on all tables in all databases, and the password is set to 123.

mysql>grant All privileges on * * to [email protected] identified by ' 123′;

Assign the native user EE permission to perform all operations on all tables in all databases, and set the password to 123.


3. Delete a user

@>mysql-u root-p

@> Password

Mysql>delete from Mysql.user WHERE user= "Tome"

Mysql>flush privileges;

Delete a user's database

Mysql>drop database tomedb;


4. Modify the specified user password

@>mysql-u root-p

@> Password

Mysql>update Mysql.user Set Password=password (' New password ') where user= "Tome" and host= "localhost";

Mysql>flush privileges;

mysql>quit;


5. If you cannot connect to a local library using root:

Tip: 1045 Access denied for user ' root ' @ ' localhost ' using password Yes

Method One:

#/etc/init.d/mysql Stop

# Mysqld_safe--user=mysql--skip-grant-tables--skip-networking &

# mysql-u Root MySQL

mysql> UPDATE user SET Password=password (' NewPassword ') where user= ' root ';

mysql> FLUSH privileges;

Mysql> quit

#/etc/init.d/mysql Restart

# mysql-uroot-p

Enter Password: < Enter the newly set password newpassword>

Mysql>


Method Two:

Use the user name and password provided directly in the [client] section of the/etc/mysql/debian.cnf file:

# mysql-udebian-sys-maint-p

Enter Password: < Enter the password for the [client] section >

mysql> UPDATE mysql.user SET password=password (' NewPassword ') where user= ' root ';

mysql> FLUSH privileges;

Mysql> quit

# mysql-uroot-p

Enter Password: < Enter the newly set password newpassword>

Mysql>


Issues such as creating users and assigning permissions to MySQL under Linux

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.