設置更改root密碼、鏈接mysql、mysql命令

13.1 設置更改root密碼

  1. /usr/local/mysql/bin/mysql -uroot
  2. 更改環境變量PATH,增長mysql絕對路徑 mysqladmin -uroot password '123456' mysql -uroot -p123456
  3. 密碼重置 vi /etc/my.cnf//增長skip-grant
  4. 重啓mysql服務 /etc/init.d/mysqld restart
  5. mysql -uroot
  6. use mysql;
  7. update user set password=password('aminglinux') where user='root';

13.2 鏈接mysql

  1. mysql -uroot -p123456
  2. mysql -uroot -p123456 -h127.0.0.1 -P3306
  3. mysql -uroot -p123456 -S/tmp/mysql.sock
  4. mysql -uroot -p123456 -e 「show databases」

13.3 mysql經常使用命令

  1. 查詢庫 show databases;
  2. 切換庫 use mysql;
  3. 查看庫裏的表 show tables;
  4. 查看錶裏的字段 desc tb_name;
  5. 查看建表語句 show create table tb_name\G;
  6. 查看當前用戶 select user();
  7. 查看當前使用的數據庫 select databsase();
  8. 建立庫 create database db1;
  9. 建立表 use db1; create table t1(id int(4), name char(40));
  10. 查看當前數據庫版本 select version();
  11. 查看數據庫狀態 show status;
  12. 查看各參數 show variables; show variables like 'max_connect%';
  13. 修改參數 set global max_connect_errors=1000;
  14. 查看隊列 show processlist; show full processlist;

擴展

  1. mysql5.7 root密碼更改 http://www.apelearn.com/bbs/thread-7289-1-1.html
  2. myisam 和innodb引擎對比 http://www.pureweber.com/article/myisam-vs-innodb/
  3. mysql 配置詳解: http://blog.linuxeye.com/379.html
  4. mysql調優: http://www.aminglinux.com/bbs/thread-5758-1-1.html
  5. 同窗分享的親身mysql調優經歷: http://www.apelearn.com/bbs/thread-11281-1-1.html
相關文章
相關標籤/搜索