考虑到很多孩子不会Linux或Mysql,所以我这里提示一下,

这篇教程里 "有多行代码" 的是给你展示结果的,不用你敲

只有一行的才是要你自己敲进去的.

 

1.首先更新一下仓库

sudo apt-get update
2.安装mysql sudo apt-get install -y mysql-server mysql-client
3.检查mysql是否已运行 sudo netstat -tap | grep mysql
有显示就是已运行 4.查询默认的用户名和密码 (提示:sudo命令会让你输入你的用户密码,就是你的开机密码,并且你输入的时候看不到自己输入的内容,不要以为电脑卡住了,输完回车就行) sudo cat /etc/mysql/debian.cnf
显示出来的内容格式如下(我的密码,跟你不一样) baiguo@baiguo-PC:~$ sudo cat /etc/mysql/debian.cnf
# Automatically generated for Debian scripts. DO NOT TOUCH!
[client]
host = localhost
user = debian-sys-maint
password = F64nKZ233QkzL8v9
socket = /var/run/mysqld/mysqld.sock
[mysql_upgrade]
host = localhost
user = debian-sys-maint
password = F64nKZ233QkzL8v9
socket = /var/run/mysqld/mysqld.sock
其中user代表的用户名,password代表的默认生成的密码 5.利用默认账号密码登录(-p后面是我的密码,你们要把自己的密码放在那里,并且-p跟密码之间无空格) mysql -u debian-sys-maint -pF64nKZ233QkzL8v9
成功进入mysql,有如下显示: baiguo@baiguo-PC:~$ mysql -u debian-sys-maint -pF64nKZ233QkzL8v9
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.21-1 (Debian) Copyright (c) 2000, 2018, 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' for help. Type '\c' to clear the current input statement. mysql>
6.现在更改密码的设置.(原封不动复制过去,漏一个字你就完了),这是最重要的部分,很多教程都没有这个,所以才不管用
update mysql.user set plugin="mysql_native_password" where user="root";
成功后结果如下: mysql> update mysql.user set plugin="mysql_native_password" where user="root";
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0 mysql>
7.设置root的密码 update mysql.user set authentication_string=password('这里是你的密码') where user='root'and Host = 'localhost';
密码自己设置 8.退出数据库 exit
9.重新启动数据库 sudo service mysql restart
10.用自己设置好的密码登录 mysql -u root -p
输入密码,成功登录,如下. baiguo@baiguo-PC:~$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.21-1 (Debian) Copyright (c) 2000, 2018, 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' for help. Type '\c' to clear the current input statement. mysql> nice!
---------------------

最新文章

  1. HTML5笔记1——HTML5的发展史及标签的改变
  2. 返回人民币大写方式(num2rmb)
  3. Spark 官方文档(4)——Configuration配置
  4. 鼠绘漫画 for wp8.1
  5. okHttp使用
  6. 【转】easyui $.message.alert 点击右上角的关闭按钮时,不执行定义的回调函数
  7. 很少再用left join
  8. Hibernate一对一关联映射配置
  9. ueditor集成自己的ImageServer时出现错误的原因分析
  10. Android 6.0 SDK 找不到HttpClient的解决方法
  11. 在VC6.0中编译头文件时产生moc文件
  12. git批量删除分支
  13. 关于IE下AJAX的问题探讨
  14. MapperScannerConfigurer(转)
  15. 安卓模拟器Android SDK Manager 无法获取SDK列表的解决办法
  16. qt example
  17. ecstore在MySQL5.7下维护报错WARNING:512 @ ALTER IGNORE TABLE
  18. matlab 嵌套循环的学习
  19. vue-cli axios跨域 + 反向代理模拟http请求host+referer
  20. LCD_FSMC

热门文章

  1. Django模型类之models字段类型和参数以及元数据meta
  2. 『Python』skimage图像处理_旋转图像
  3. 更改 Windows 软件默认安装位置教程
  4. 四则运算Java语言实验设计过程1
  5. Oracle 11.2.0.4.0 Dataguard部署和日常维护(4)-Datauard Gap事件解决篇
  6. [Codeforces Round #340 (Div. 2)]
  7. python http 请求 响应 post表单提交
  8. suffix word ality ally an ancy ance an aneity out ~1
  9. @Configuration的使用 和作用
  10. java的小程序在html中的运行测试