MySQL mo MySQL is not set password, under normal circumstances or should be set up a password.
[Email protected] ~]# Mysql-uroot
Quit with quit.
Set a password for MySQL
[Email protected] ~]# mysqladmin-uroot password ' zaq12wsx '
If we forget the MySQL password, how to solve it?
Initialize password
[email protected] ~]# vim/etc/my.cnf #编辑my. CNF
Skip-grant #加上这一行
Restart MySQL, you can go straight in, do not need to enter a password.
[Email protected] ~]#/etc/init.d/mysqld restart
Stopping mysqld: [OK]
Starting mysqld: [OK]
After entering
mysql> use MySQL #使用mysql库
mysql> Update user Set Password=password (' zaq12wsx ') where user= ' root ';
#更新一个表, change the root user's password. Note the syntax.
Query OK, 2 rows Affected (0.00 sec) This line has changed.
mysql> SELECT * from user where user= ' root ' \g; #查看可以看到用户 & Password.
1. Row ***************************
Host:localhost
User:root
Password: *839e2e02728dfba36c0389417509643bfca1f91c
Select_priv:y
Insert_priv:y
Update_priv:y
Delete_priv:y
——————————————————————————————————————————
Change the configuration file
[email protected] ~]# vim/etc/my.cnf #编辑my. CNF
Skip-grant #删除这一行
Restart MySQL, and then re-enter, you will be prompted to require a password to enter.
Reset the password to the end.
———————————————————————————————————————————————
MySQL Log in
[[email protected] ~]# MYSQL-UROOT-PZAQ12WSX # Local Login
[Email protected] ~]# MYSQL-UROOT-H10.72.4.30-P3306-PZAQ12WSX
ERROR 1130 (HY000): Host ' 10.72.4.30 ' isn't allowed to connect to this MySQL server
[[Email protected] ~]# telnet 10.72.4.30 3306 # test is not connected
Trying 10.72.4.30 ...
Connected to 10.72.4.30.
Escape character is ' ^] '. #连通没有问题, but cannot be linked, because there is no authorization.
Chost ' 10.72.4.30 ' is not a allowed to connect to this MySQL serverconnection closed by foreign host.
Go to MySQL
Authorization statement
Mysql> Grant All on * * to ' root ' @ ' 10.72.4.30 ' identified by ' 123456 ';
# * represents all the libraries, the second * represents all tables, together, all the tables of all libraries.
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect ...
Connection id:11
Current database: * * * NONE * * *
Query OK, 0 rows Affected (0.00 sec) # Authorized success
mysql> use MySQL
Database changed
Mysql> SELECT * from user where host= ' 10.72.4.30 ' \g;
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect ...
Connection id:17
Current Database:mysql
1. Row ***************************
host:10.72.4.30
User:root
Password: *6bb4837eb74329105ee4568dda7dc67ed2ca2ad9
Select_priv:y
Insert_priv:y
Update_priv:y
Delete_priv:y
Create_priv:y
Drop_priv:y
Reload_priv:y
Shutdown_priv:y
Process_priv:y
File_priv:y
_________________________________________________________________________
[Email protected] ~]# mysql-uroot-h10.72.4.30-p3306-p123456 # Test Login,
Mysql> Select User (); #查看当前登陆的用户
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect ...
Connection id:20
Current database: * * * NONE * * *
+-----------------+
| User () |
+-----------------+
| [Email protected] |
+-----------------+
1 row in Set (0.00 sec)
This article is from the "Cbo#boy_linux Road" blog, make sure to keep this source http://20151213start.blog.51cto.com/9472657/1858592
1~2_mysql configuration password reset & Mysql Login