Ubuntu18.04 mysql command-line installation is not prompted for a password, change the default password mysql
mysql default password is blank
However, when using mysql -uroot -p mysql connection command, error
ERROR 1045 (28000): Access denied for user 'root' @ 'localhost'
At this point modify the default root password
1. Go to the etc / mysql directory, file viewing debian.cnf
2. Find a user name, password, use this account to log mysql
Username: debian-sys-maint
Password: eWzuvU1nrS0nzHIO
Login: mysql -udebian-sys-maint -peWzuvU1nrS0nzHIO
3. Modify the root password of a user
here is the key point, since there is no mysql5.7 password field, the password is stored in the field authentication_string, password () method can also use
Execute the following statement to change the password in mysql
1 show databases; 2 use mysql; 3 update user set authentication_string=PASSWORD("yourpassword") where user='root'; 4 update user set plugin="mysql_native_password"; 5 flush privileges; 6 exit;
4. After you change your password, you need to restart mysql
1 /etc/init.d/mysql restart;
Login again
MySQL - -uroot - the p-code;