首先要安装服务端和客服端
sudo apt-get install mysql-server //服务端 sudo apt-get install mysql-client //客户端
sudo netstat -tap | grep mysql
会显示mysql服务的端口号和pid
mysql -u root -p
如果忘了密码就查询默认密码:
进入到etc/mysql 目录下,查看debian.cnf文件
debian.cnf # Automatically generated for Debian scripts. DO NOT TOUCH! [client] host = localhost user = debian-sys-maint password = pASsYAUR2aRiaprZX socket = /var/run/mysqld/mysqld.sock [mysql_upgrade] host = localhost user = debian-sys-maint password = pASsYAUR2aRiaprZX socket = /var/run/mysqld/mysqld.sock
默认用户登录 mysql -u debian-sys-maint -p 修改root密码 mysql> use mysql; mysql> update user set authentication_string=password('1234qwer') where user='root' and Host ='localhost'; mysql> update user set plugin="mysql_native_password"; mysql> flush privileges; mysql> quit;
登录密码
mysql -uroot -p1234qwer
就可以正常登录数据库了
参考文档
https://www.cnblogs.com/csig/p/12077928.html
https://www.cnblogs.com/lfri/p/10437694.html