Linux(Ubuntu)
root@ubuntu-virtual-machine:~# mysql_secure_installation
Securing the MySQL server deployment.
Connecting to MySQL using a blank password.
VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin? # 要安裝驗證密碼插件嗎?
Press y|Y for Yes, any other key for No: N # 這里我選擇N
Please set the password for root here.
New password: # 輸入要為root管理員設(shè)置的數(shù)據(jù)庫密碼
Re-enter new password: # 再次輸入密碼
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y # 刪除匿名賬戶
Success.
Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : N # 禁止root管理員從遠(yuǎn)程登錄谍咆,這里我沒有禁止
... skipping.
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y # 刪除test數(shù)據(jù)庫并取消對它的訪問權(quán)限
- Dropping test database...
Success.
- Removing privileges on test database...
Success.
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y # 刷新授權(quán)表缚态,讓初始化后的設(shè)定立即生效
Success.
All done!
如果這樣還是不行狂窑,沒有效果
先進Mysql
mysql -uroot
>use mysql;
>select * from user where User='root';
//這里肯定會顯示一大堆東西空镜,其實是因為表橫向太長,顯示不全的原因
+---------------------------------+-------------------------------------------------------------------------------+
| plugin | authentication_string |
+---------------------------------+-------------------------------------------------------------------------------+
| mysql_native_password | *84AAC12F54AB666ECFC2A83C676908C8BBC381B1 |
+---------------------------------+-------------------------------------------------------------------------------+
把這兩個地方改成這樣就行了
>update user set plugin='mysql_native_password',authentication_string='*84AAC12F54AB666ECFC2A83C676908C8BBC381B1' where User='root';
這樣你的root用戶密碼咳焚,就改成了12345678
可以盡情的學(xué)數(shù)據(jù)庫了洽损。