标签:linux
十三周四次课(3月22日)
1.设置root密码
mysqladmin -uroot password '123456' #设置mysql的root密码为123456
mysql -uroot -p123456 #登录mysql
2.更改密码
mysqladmin -uroot -p'123456' password '654321' #将mysql的root密码更改为654321
3.重置密码
vi /etc/my.cnf
在[mysqld]中增加skip-grant (目的是让我们能不用密码就可登录mysql)
/etc/init.d/mysqld restart #重启mysql服务,让配置生效
mysql -uroot
use mysql;
update user set password=password('123456') where user='root'; #将密码重置为123456
vi /etc/my.cnf //把skip-grant去掉,恢复原先配置
/etc/init.d/mysqld restart







设置密码



更改密码


重置密码













13.2 连接mysql

1.直接本地连接.
mysql -uroot -p123456
2.通过IP+端口连接,可连到远程的mysql.
mysql -uroot -p123456 -h127.0.0.1 -P3306
3.通过sock来连接,只适合在本机使用.
mysql -uroot -p123456 -S/tmp/mysql.sock
4.连接同时执行sql命令,适合在shell脚本中使用.
mysql -uroot -p123456 -e "show databases;"



13.3 mysql常用命令























扩展
mysql5.7 root密码更改
http://www.apelearn.com/bbs/thread-7289-1-1.html
myisam 和innodb引擎对比
http://www.pureweber.com/article/myisam-vs-innodb/
mysql 配置详解:
http://blog.linuxeye.com/379.html
mysql调优:
http://www.aminglinux.com/bbs/thread-5758-1-1.html
同学分享的亲身mysql调优经历:
http://www.apelearn.com/bbs/thread-11281-1-1.html
标签:linux
原文地址:http://blog.51cto.com/4375471/2090073