sudo apt install mysql-server
登录mysql
sudo mysql -u root -p
新增用户
CREATE USER 'admin'@'%' IDENTIFIED BY 'pass12345';grant all privileges on *.* to 'admin'@'%';
--------------以下没用--------------------
方法一:默认账户登录
查看密码使用sudo cat /etc/mysql/debian.cnf这条查看
bot@ubuntu:~/Desktop/python/django/2$ sudo cat /etc/mysql/debian.cnf
[sudo] bot 的密码:
Automatically generated for Debian scripts. DO NOT TOUCH!
[client]
host = localhost
user = debian-sys-maint
password = SffnwAJrKhIFZ2tO
socket = /var/run/mysqld/mysqld.sock
[mysql_upgrade]
host = localhost
user = debian-sys-maint
password = SffnwAJrKhIFZ2tO
socket = /var/run/mysqld/mysqld.sock