HuangHongRui / huanghongrui.github.io

:poultry_leg: MyBlog | Keep track of every moment.. :icecream:
http://blog.luckyman.xyz/
3 stars 1 forks source link

MYSQL #38

Open HuangHongRui opened 5 years ago

HuangHongRui commented 5 years ago

MySQL -Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

It work for me ..

/usr/sbin/mysqld --defaults-file=/etc/mysql/my.cnf --basedir=/usr --datadir=/var/lib/mysql --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/run/mysqld/mysqld.sock

Article

HuangHongRui commented 5 years ago

忘记Mysql密码了,怎么办.

版本: 5.7.25 操作步骤:

  1. $ vi /etc/my.conf #打开配置
  2. $ skip-grant-tables #末尾插入此行
  3. $ service mysql restart #重启动Mysql
  4. $ mysql #启动
  5. > ALTER USER 'root'@'localhost'IDENTIFIED BY 'PASSWORD' #设置密码

如果 步骤5 报错: The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement

  • > flush privileges; #Mysql>执行该命令
  • 继续跑 步骤5 即可更改成功 :)
HuangHongRui commented 5 years ago

常用命令

显示所有数据库:

使用指定数据库

查看当前使用的数据库

查看数据中所有字段与类型:

查看数据中所有字段:

查看表数据