安装数据库服务端和客户端
sudo apt install mysql-server mysql-client
安装过程中记得等一下,否则会忘记设置密码,像我就直接Yes而忘记设置密码,不过有相应解决方案。
修改配置,无密码登录
sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf 在这个配置文件中的[mysqld]这一块中加入 skip-grant-tables 这句话 。
重启服务器 : service mysql restart
登录: mysql -u root -p 回车,输密码再回车进入mysql命令行
按如下命令教程操作,设置root和密码
whch@whch:/usr/share/mysql$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.27-0ubuntu0.19.04.1 (Ubuntu)
Copyright (c) 2000, 2019, 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' f