1. New user
//login MYSQL
@>mysql -u root -p
@>password
//create user
mysql> insert into mysql.user(Host,User,Password) values('localhost','jeecn',password(' jeecn'));
//Refresh the system privilege table
mysql>flush privileges;
This creates a user named: jeecn and password: jeecn.
//Log in
mysql>exit after exiting;
@>mysql -u jeecn -p
@>Enter the password
mysql>Login successfully
2. Authorize the user
//Log in to MYSQL (with ROOT privilege). I am logged in as ROOT.
@>mysql -u root -p
@>password
//First create a database for the user (jeecnDB)
mysql>create database jeecnDB;
//Authorize jeecn user to have all privileges on jeecn database
@>grant all privileges on jeecnDB.* to jeecn @localhost identified by 'jeecn';
//Refresh the system privilege table
mysql>flush privileges;
mysql>other operations
//If you want to assign some privileges to a user, you can write:
mysql>grant select,update on jeecnDB.* to jeecn@localhost identified by 'jeecn' ;
//Refresh the system permission table.
mysql>flush privileges;
mysql> grant permission 1, permission 2, ... permission n on database name. Table name to username@user address identified by 'connection password';
permission 1, permission 2, ... permission n represents select, insert, update, delete, create, drop, index, alter, grant, references, reload, shutdown, process , file and other 14 permissions.
When permission 1, permission 2, ... permission n are replaced by all privileges or all, it means that all permissions are granted to the user.
When the database name. The table name is replaced by *.*, which means that the user is authorized to operate all tables in all databases on the server.
The user address can be localhost, or it can be an ip address, a machine name, or a domain name. You can also use '%' to connect from any address.
'Connection password' cannot be empty, otherwise the creation fails.
E.g:
mysql>grant select, insert, update, delete, create, drop on vtdc.employee to [email protected] identified by '123';
assign user jee from 10.163.225.87 to select and insert the employee table of database vtdc ,update,delete,create,drop and other operations permissions, and set the password to 123.
mysql>grant all privileges on vtdc.* to [email protected] identified by '123';
assign the user jee from 10.163.225.87 the authority to perform all operations on all tables in the database vtdc, and set the password to 123.
mysql>grant all privileges on *.* to [email protected] identified by '123';
assign the user jee from 10.163.225.87 the authority to perform all operations on all tables in all databases, and set the password to 123.
mysql>grant all privileges on *.* to jee@localhost identified by '123';
assign the local user jee the authority to perform all operations on all tables in all databases, and set the password to 123.
3. Delete user
@>mysql -u root -p
@>password
mysql>DELETE FROM mysql.user WHERE User=”jeecn”
mysql>flush privileges;
//Delete the user's database
mysql>drop database jeecnDB;
4. Modify the specified user password
@>mysql -u root -p
@>password
mysql>update mysql.user set password=password('new password') where User=”jeecn” and Host=”localhost”;
mysql>flush privileges;
mysql>quit;
5. If root cannot connect to the local library:
prompt: 1045 access denied for user 'root'@'localhost' using password yes
was fine a few days ago, but I didn't get it yesterday, but I came here tonight and prompted the above error, restarting mysql is still not possible. I have read a few
online methods but don't know how
Method 1:
# /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 new Set password newpassword>
mysql>
Method 2:
Use the username and password provided in the [client] section of the /etc/mysql/debian.cnf file directly:
# mysql -udebian-sys-maint -p
Enter password: <input [client] section password>
mysql> UPDATE mysql.user SET Password=PASSWORD('newpassword') where USER='root';
mysql> FLUSH PRIVILEGES;
mysql> quit
# mysql -uroot -p
Enter password: <Enter the new password newpassword >
mysql>
;
The above is transferred from http://blog.csdn.net/wuzhilon88/article/details/40376959
When configuring the case-ignoring parameter lower_case_table_names=1 in the mysql database, this sentence was placed under [mysqld] before, so that the data created by itself could not be loaded after startup. The correct way is to put it under [mysqld_safe].
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
[mysqld_safe]
log-error= /var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
lower_case_table_names=1
MySQL user creation and authorization and parameter configuration
Guess you like
Origin http://10.200.1.11:23101/article/api/json?id=326615200&siteId=291194637
Recommended
Ranking