1.修改mysqld.cnf配置文件
sudo gedit /etc/mysql/mysql.conf.d/mysqld.cnf,进入到这个配置文件,然后在这个配置文件中中加入skip-grant-tables这句话。
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking
character-set-server=utf8
collation-server=utf8_general_ci
skip-grant-tables <-- add here
service mysql restart 重启mysql
2.重设root密码
use mysql;
update user set authentication_string=PASSWORD("888888") where User='root';
update user set plugin="mysql_native_password" where User='root'; # THIS LINE
flush privileges;
quit;
3.注释掉skip-grant-tables
再返回终端输入mysql -u root -p,应该就可以进入数据库了。
MyISAM与InnoDB 的区别
- InnoDB 支持事务
- InnoDB 为行锁
- InnoDB 为聚集索引,必须要有主键
- InnoDB select count(*) from table要进行全表扫描