啓動mysql而後將/usr/local/mysql/bin/臨時添加到環境變量html
export PATH=$PATH:/usr/local/mysql/bin
永久添加則將上面命令添加到/etc/profile中mysql
而且執行source /etc/profilelinux
source /etc/profile
使用mysql -uroot使用mysql : 適用沒設置密碼時web
[root@yolks2 ~]# mysql -uroot Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.6.39 MySQL Community Server (GPL) 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>
設定root密碼sql
mysqladmin -uroot password 'mysql123' #設置root用戶密碼爲123
設定以後再使用mysql -uroot就已經不能夠登錄了:提示拒絕shell
[root@yolks2 ~]# mysql -uroot ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
使用用戶名+密碼登陸 :建議密碼加單引號數據庫
mysql -uroot -pmysql123
修改密碼:從mysql123 修改成 mysql123456.net
mysqladmin -uroot -p'mysql123' password 'mysql123456'
密碼重置rest
1.修改配置文件 /etc/my.cnf ,mysqld位置增長skip-grant(忽略受權,即免密碼登陸)code
skip-grant
2.重啓mysql
/etc/init.d/mysqld restart
3.免密登陸mysql -uroot
4.切換到mysql庫
use mysql;
5.修改mysql庫下的user表
update user set password=password('mysql123') where user='root';
查詢user表下的密碼列
select password from user; +-------------------------------------------+ | password | +-------------------------------------------+ | *F861720E101148897B0F5239DB926E756B1C28B3 | | *F861720E101148897B0F5239DB926E756B1C28B3 | | *F861720E101148897B0F5239DB926E756B1C28B3 | | *F861720E101148897B0F5239DB926E756B1C28B3 | | | | | +-------------------------------------------+ 6 rows in set (0.00 sec)
6.修改完以後再去掉mysql配置文件的skip-grant
id
int(4),name
varchar(20)); : 建立數據表mysql命令歷史紀錄文件 : .mysql_history
mysql5.7 root密碼更改 http://www.apelearn.com/bbs/thread-7289-1-1.html
myisam 和innodb引擎對比 http://www.pureweber.com/article/myisam-vs-innodb/
知乎上的答案 https://www.zhihu.com/question/20596402
mysql 配置詳解:https://www.jb51.net/article/48082.htm
mysql調優: http://www.aminglinux.com/bbs/thread-5758-1-1.html
同窗分享的親身mysql調優經歷: http://www.apelearn.com/bbs/thread-11281-1-1.html