报权限错误Failed to set datadir to '/var/lib/mysql/' (OS errno: 13 - Permission denied) 这里看起来是没有权限,则删除了/var/lib/mysql文件夹下所有的数据就好了rm -rf /var/lib/mysql/*(安装之前本来是删除过的,不知道咋回事)
3.3. 查看默认密码
在日志中查看密码
1
grep "temporary password" /var/log/mysqld.log
会打印默认密码 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: wyaNYeKI<5Xx 其中wyaNYeKI<5Xx就是密码
Enter password for user root: //输入默认密码 The 'validate_password' component is installed on the server. The subsequent steps will run with the existing configuration of the component. Using existing password for root.
Estimated strength of the password: 100 Change the password for root ? ((Press y|Y for Yes, any other key for No) : y
New password: //输入新密码
Re-enter new password:
Estimated strength of the password: 100 Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y //确认,因为不安全,需要确认一下 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) : y //禁止root远程访问,这个一般是禁止的,可以在数据库新建一个账号远程连接 Success.
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 //移除测试数据库 - 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 //立即刷新权限,一般选择y,马上生效 Success.