新版MySql 5.6.20、インストール後にログインできない解決方法

2312 ワード

1.       mysql

2.  cmd   mysql     ,      C:\Program Files\MySQL\MySQL Server 5.6\bin
       cd C:\Program Files\MySQL\MySQL Server 5.6\bin

3.  mysqld mysql     ,   :mysqld -install MySQL

4.    :net start MySQL

5.    ,  root         ,      
  mysql -u root -p

6.①  show databases;
  ②  use mysql;
  ③  SET PASSWORD FOR 'root'@'localhost' = PASSWORD('123456');
  ④  quit;

        
#            user,     123456,                            ,    3306
GRANT all privileges on *.* TO 'user'@'%' identified by '123456' WITH GRANT OPTION;  
FLUSH PRIVILEGES;  

#mysql     user1          db123,     333333
grant all privileges on db123.* to 'user1'@'%' identified by '333333' with grant option;  
FLUSH PRIVILEGES;

#mysql     user2          db123,     666666,         IP 
grant all privileges on db123.* to 'user2'@'192.168.104.%' identified by '666666' with grant option;  
FLUSH PRIVILEGES;
MySQL    ,  ,    ,    

1.    。

//  MYSQL
@>mysql -u root -p
@>  
//    
mysql> insert into mysql.user(Host,User,Password) values("localhost","phplamp",password("1234"));
//       
mysql>flush privileges;
          :phplamp     :1234     。

      。

mysql>exit;
@>mysql -u phplamp -p
@>    
mysql>    

2.     。

//  MYSQL( ROOT  )。    ROOT    .
@>mysql -u root -p
@>  
//            (phplampDB)
mysql>create database phplampDB;
//  phplamp    phplamp        。
>grant all privileges on phplampDB.* to phplamp@localhost identified by '1234';
//       
mysql>flush privileges;
mysql>    

/*
             ,      :
mysql>grant select,update on phplampDB.* to phplamp@localhost identified by '1234';
//       。
mysql>flush privileges;
*/

3.    。
@>mysql -u root -p
@>  
mysql>DELETE FROM user WHERE User="phplamp" and Host="localhost";
mysql>flush privileges;
//        
mysql>drop database phplampDB;

4.        。
@>mysql -u root -p
@>  
mysql>update mysql.user set password=password('   ') where User="phplamp" and Host="localhost";
mysql>flush privileges;