deepin安装mysql密码问题解决方案
Tofloor
poster avatar
180******02
deepin
2018-10-10 18:20
Author
deepin安装mysql密码问题解决方案

1.安装mysql
  更新仓库:sudo apt-get update
  安装:sudo apt-get install mysql-server mysql-client
  问题:安装mysql5.7的过程中 无root密码设置提示 直接安装完成结束
2.不知道密码状态下打开mysql
  查询mysql是否运行:sudo netstat -tap |grep mysql
  (有显示就表示已运行)
  备注:mysql 打开(service mysql start) 关闭(service mysql stop) 重启命令(service mysql restart)
  查询默认的用户名和密码:sudo cat /etc/mysql/debian.cnf
        baiguo@baiguo-PC:~$ sudo cat /etc/mysql/debian.cnf
        # Automatically generated for Debian scripts. DO NOT TOUCH!
        [client]
        host     = localhost
        user     = debian-sys-maint
        password = F64nKZ233QkzL8v9
        socket   = /var/run/mysqld/mysqld.sock
        [mysql_upgrade]
        host     = localhost
        user     = debian-sys-maint
        password = F64nKZ233QkzL8v9
        socket   = /var/run/mysqld/mysqld.sock
   备注:这样比较麻烦,无法复制密码,可以直接打开你的文件管理器,用管理员身份打开debian.cnf即可查看复制密码
   利用默认账户进行登录:mysql -u debian-sys-maint -p(文件中的密码,与p之间不要有空格)
3.进入mysql修该密码
        这句必须:update mysql.user set plugin="mysql_native_password" where user="root";
        设置root账户密码:update mysql.user set authentication_string=password('这里是你的密码') where user='root'and Host = 'localhost';
4.退出数据库
        exit
        重新启动数据库

        sudo service mysql restart

        用自己设置好的密码登录

        mysql -u root -p

        输入密码,成功登录,如下.

        baiguo@baiguo-PC:~$ mysql -u root -p
        Enter password:
        Welcome to the MySQL monitor.  Commands end with ; or \g.
        Your MySQL connection id is 4
        Server version: 5.7.21-1 (Debian)

        Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

        Oracle is a registered trademark of Oracle Corporation and/or its
        affiliates. Other names may be trademarks of their respective
        owners.

        Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

        mysql>



        同学 你成功了!


Reply Favorite View the author
All Replies
avatar
zhangslob
deepin
2018-10-10 21:41
#1
已经放弃安装了,直接来Docker  
http://www.runoob.com/docker/docker-install-mysql.html
Reply View the author
avatar
AlanHoo
deepin
2018-10-28 23:42
#2
找了两小时才找到正确的解决方案,感谢大佬
Reply View the author
avatar
liu154019551
deepin
2018-11-03 17:41
#3
感谢大佬的无私付出,小白感激不尽
Reply View the author
avatar
唯二
deepin
2018-12-06 19:11
#4
感谢大佬的MySQL教程,我找了好久,在您这终于解决了,太感谢了
Reply View the author
avatar
liyingsong
deepin
2018-12-17 06:55
#5
66666666666
Reply View the author
avatar
工地搬砖老能手
deepin
2018-12-19 07:56
#6
我去,看了这么多博客。这才是正解~~~
Reply View the author
avatar
louis-yzk
deepin
2019-01-13 04:44
#7
解决了,谢谢~
Reply View the author
avatar
daniel-cui
deepin
2019-01-16 23:30
#8
貌似不用那么费劲, 这样就可以了
sudo mysql -u root
mysql> create user 'xxxxxx'@'localhost' identified by 'mysql';
mysql> grant all on *.* to 'xxxxxx'@'localhost';
mysql> update user set password=password('password') where user='xxxxxx' and host='localhost';
mysql> flush privileges;
Reply View the author
Comments
manechao
2019-06-24 05:26
正解~
avatar
130******92
deepin
2019-02-19 01:08
#9
按照楼主的指引,已经能用root身份登陆了,但是这个root用户,没有任何权限(privileges)。再增加一个mysql 语句:grant all on *.* to root@"localhost" ,赋予root所有的权限。问题解决了。
Reply View the author
avatar
shz__shz2000
deepin
2019-02-19 04:43
#10
学习了,已收藏。
Reply View the author
avatar
李健
deepin
2019-03-09 06:58
#11
标记一个
Reply View the author
avatar
wayne173
deepin
2019-03-11 05:51
#12
其实刚装好后可以直接 sudo mysql -uroot -p
这个时候数不输入密码都可以进入的。一开始感觉很奇怪,其实是plugin 的原因。
之后的操作和楼主的一样。
Reply View the author
avatar
svod5306
deepin
2019-04-20 00:53
#13
同学,莫得配置文件怎么没密码:
[client]
host     = localhost
user     = root
password =
socket   = /var/run/mysqld/mysqld.sock
[mysql_upgrade]
host     = localhost
user     = root
password =
socket   = /var/run/mysqld/mysqld.sock
basedir  = /usr
Reply View the author
avatar
disneyliao
deepin
2019-04-22 01:34
#14
本帖最后由 disneyliao 于 2019-4-21 17:37 编辑

我每次安装好了之后,第一天启动连接没问题,第二天用mysql -u root -p的时候 报错
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysql.sock' 快整崩溃了!
Reply View the author
avatar
fzpp
deepin
2019-07-06 02:27
#15
https://bbs.deepin.org/post/169658
同学,莫得配置文件怎么没密码:
[client]
host     = localhost

sudo mysql -u root -p 后让输入密码时直接回车
Reply View the author
avatar
joey2miao
deepin
2019-07-16 00:01
#16
感谢大佬
Reply View the author
avatar
kenzgoingon
deepin
2019-10-05 01:56
#17
感谢分享~
Reply View the author