download mysql deb

[下载地址](https://dev.mysql.com/downloads/repo/apt/)

install deb

[文档地址](https://dev.mysql.com/doc/mysql-apt-repo-quick-guide/en/)

apt install mysql-server

get root password

登录时不需要使用密码,提示找不到 UNIX socket

1
2
3
4
5
6
7
8
9
chen@chen-YangTianT4900c-00:~/download$ sudo mysqld_safe --skip-grant-tables --skip-syslog --skip-networking

Logging to '/var/lib/mysql/chen-YangTianT4900c-00.err'.
2018-09-06T02:56:11.619644Z mysqld_safe Directory '/var/run/mysqld' for UNIX socket file don't exists.

chen@chen-YangTianT4900c-00:~/download$ sudo -u mysql mysqld_safe --skip-grant-tables --skip-syslog --skip-networking

2018-09-06T02:56:18.987750Z mysqld_safe Logging to '/var/lib/mysql/chen-YangTianT4900c-00.err'.
2018-09-06T02:56:18.993047Z mysqld_safe Directory '/var/run/mysqld' for UNIX socket file don't exists.

创建mysqld文件夹,给与权限

1
2
sudo mkdir /var/run/mysqld
chen@chen-YangTianT4900c-00:~/download$ sudo chmod 777 /var/run/mysqld

登录

1
mysql -u root

修改密码,密码可从其他数据库上拷

1
2
update mysql.user set plugin='mysql_native_password', authentication_string='*8B98A17FF7D791BC9F0216DDC7658432C4B866FB' where user='root';
FLUSH PRIVILEGES;

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
thanks to @thusharaK I could reset the root password without knowing the old password.

On ubuntu I did the following:

sudo service mysql stop
sudo mysqld_safe --skip-grant-tables --skip-syslog --skip-networking
Then run mysql in a new terminal:

mysql -u root
And run the following queries to change the password:

UPDATE mysql.user SET authentication_string=PASSWORD('password') WHERE User='root';
FLUSH PRIVILEGES;
In MySQL 5.7, the password field in mysql.user table field was removed, now the field name is 'authentication_string'.

Quit the mysql safe mode and start mysql service by:

mysqladmin shutdown
sudo service mysql start

最后更新: 2019年07月06日 16:45

原始链接: https://chenadminchen.github.io/2018/09/06/mint-install-mysql8/

× 请我吃糖~
打赏二维码