ubuntu下安装mysql 5.7时, mysql 会自动生成密码. 我们找不到的, 解决方案

访问量: 981

参考: https://stackoverflow.com/questions/42421585/default-password-of-mysql-in-ubuntu-server-16-04

mysql> use mysql;
mysql> update user set plugin="mysql_native_password";
mysql> update user set authentication_string=PASSWORD("YOUR-NEW-ROOT-PASSWORD") where User='root';
mysql> flush privileges;
mysql> quit

# service mysql stop
# service mysql start
$ mysql -u root -p

下面是老的解决方案:

修改 /etc/mysql/mysql.conf.d/mysqld.cnf

在 [mysqld] 下面,增加一行:  skip-grant-tables

 27 [mysqld]
 28 #
 29 # * Basic Settings
 30 #
 31 user    = mysql
 32 pid-file  = /var/run/mysqld/mysqld.pid
 33 socket    = /var/run/mysqld/mysqld.sock
 34 port    = 3306
 35 basedir   = /usr
 36 datadir   = /var/lib/mysql
 37 tmpdir    = /tmp
 38 lc-messages-dir = /usr/share/mysql
 39 skip-external-locking
 40 # 我加的
 41 skip-grant-tables

就可以了.

订阅/RSS Feed

Subscribe

分类/category