mysql usage

Modify password for root user

1. using root account to log on mysql

mysql>set password =password(‘yourpwd’);

mysql>flush privileges;

2. using grant statement

mysql>grant all on *.* to root@’localhost’ identified by ‘yourpwd’;

mysql>flush privileges;

3. update the user table;

mysql>update user set password=password(‘yourpwd’) where user=’root’ and host=’localhost’;

mysql>flush privileges;

Add user into mysql

using root account to log on mysql

mysql>grant all on *.* to root@% identified by ‘yourpwd’;

mysql>flush privileges;

Remove user from mysql

using root account to log on mysql

mysql>use mysql;

mysql>revoke all on *.* to root@localhost;  --revoke privileges assigned to this user

mysql>delete from user where user=’root’ and host=’localhost’;

mysql>flush privileges;

Import sql file into mysql

#>mysql –uroot –p < mysql.sql

Open remote connection

1. Check the network and port whether work well. Default port for MYSQL is 3306.

2. Check the user@’%’ whether this account exists in user.

use the administrator account log on mysql

mysql>use mysql;

mysql>select user, password, host from user;

image 

if the ‘%’ host doesnot exist in user. please add it by using ‘grant’ statement;

原文地址:https://www.cnblogs.com/rogerroddick/p/2941623.html