赞
踩
sudo apt install mysql-server
ps -elf|grep mysql
sudo service mysql start
sudo mysql_secure_installation
...
# 1.询问是否安装密码插件,我选择 No
VALIDATE PASSWORD COMPONENT 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 component?
Press y|Y for Yes, any other key for No: n
# 2.为root用户设置密码
Please set the password for root here.
New password:
Re-enter new password:
# 出现下面报错的 解决方法详见第三步,解决bug
... Failed! Error: SET PASSWORD has no significance for user 'root'@'localhost' as the authentication method used doesn't store authentication data in the MySQL server. Please consider using ALTER USER instead if you want to change authentication parameters.
# 解决bug后,重新设置密码,也可以不设置,刚刚sudo mysql设置的就是root的密码
New password:
Re-enter new password:
#3.删除匿名用户,我选No
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) : n
... skipping.
#4.禁止root管理员从远程登录,这里我选 No
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
... skipping.
#5.删除test数据库并取消对它的访问权限, 我选 No
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) : n
... skipping.
#6.刷新授权表,让初始化后的设定立即生效, 选 Yes
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
Success.
All done!
sudo mysql
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'your_password';
mysql -u root -p
开启服务 sudo service mysql start
停止服务 sudo service mysql stop
重启服务 sudo service mysql restart
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。