1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > ubuntu安装mysql 5.7未提示输入密码无法登陆的情况

ubuntu安装mysql 5.7未提示输入密码无法登陆的情况

时间:2021-04-24 10:16:47

相关推荐

ubuntu安装mysql 5.7未提示输入密码无法登陆的情况

在Ubuntu18.04通过apt-get安装mysql服务

ub64@ub64-1804-1:~$ sudo apt-get install mysql-client-core-5.7ub64@ub64-1804-1:~$ sudo apt-get install mysql-server

安装完成,中间过程并没有提示设置mysql的默认密码。不管了,先用root尝试登陆mysql试试。

ub64@ub64-1804-1:~$ mysqlERROR 1045 (28000): Access denied for user 'ub64'@'localhost' (using password: NO)ub64@ub64-1804-1:~$ mysql -u rootERROR 1698 (28000): Access denied for user 'root'@'localhost'ub64@ub64-1804-1:~$ mysql -uub64ERROR 1045 (28000): Access denied for user 'ub64'@'localhost' (using password: NO)ub64@ub64-1804-1:~$ mysql -uub64 -p123456mysql: [Warning] Using a password on the command line interface can be insecure.ERROR 1045 (28000): Access denied for user 'ub64'@'localhost' (using password: YES)

提示报错了,不管是root还是本机用户名,都无法登陆。测试一下重启服务吧,还是不行。

ub64@ub64-1804-1:~$ service mysql start==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===Authentication is required to start 'mysql.service'.Authenticating as: ub64-1804-1 (ub64)Password:==== AUTHENTICATION COMPLETE ===ub64@ub64-1804-1:~$ mysqlERROR 1045 (28000): Access denied for user 'ub64'@'localhost' (using password: NO)ub64@ub64-1804-1:~$ ps -ef | grep mysqlmysql 142851 0 05:14 ? 00:00:00 /usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pid

进程服务运行正常,但是还是登陆不上。祭出百度神器,找到同样的问题。

/super-zhangkun/p/9435974.html

好了,打开conf配置文件,查看一下默认设置的账号密码

ub64@ub64-1804-1:~$ sudo view /etc/mysql/f# Automatically generated for Debian scripts. DO NOT TOUCH![client]host= localhostuser= debian-sys-maintpassword = i1OVIwwgMWs8MAKjsocket = /var/run/mysqld/mysqld.sock[mysql_upgrade]host= localhostuser= debian-sys-maintpassword = i1OVIwwgMWs8MAKjsocket = /var/run/mysqld/mysqld.sock

原来安装完成后,默认使用的不再是以前的root了,而是使用debian-sys-maint用户和这一大串随机密码,顺利登陆。查询一下现有的用户情况。

mysql> select host, user, plugin, authentication_string from mysql.user;+-----------+------------------+-----------------------+-------------------------------------------+| host| user | plugin| authentication_string |+-----------+------------------+-----------------------+-------------------------------------------+| localhost | root | | || localhost | mysql.session | mysql_native_password | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE || localhost | mysql.sys | mysql_native_password | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE || localhost | debian-sys-maint | mysql_native_password | *2D3B703CBCBE5E317141B9EC7FA780ABB991F93E |+-----------+------------------+-----------------------+-------------------------------------------+4 rows in set (0.00 sec)

接下来为了使用方便,那就是修改一下默认的root账号的登陆设置了。由于mysql5.7的密码存储在authentication_string字段中,password()方法设置登陆密码123456。好吧,虽然不知道什么意思,但是和debian-sys-maint一样,修改默认的认证方式为"mysql_native_password"。

mysql> update mysql.user set authentication_string=password('123456') where user='root'and Host = 'localhost';Query OK, 0 rows affected, 1 warning (0.00 sec)Rows matched: 1 Changed: 0 Warnings: 1mysql> update mysql.user set plugin="mysql_native_password" where user='root'and Host = 'localhost';Query OK, 0 rows affected (0.00 sec)Rows matched: 1 Changed: 0 Warnings: 0mysql> flush privileges;Query OK, 0 rows affected (0.00 sec)

测试使用root用户登录完成,ok。

主要转载、修改参考来源:/super-zhangkun/p/9435974.html

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。