設置更改root密碼、鏈接mysql、mysql命令
13.1 設置更改root密碼
- /usr/local/mysql/bin/mysql -uroot
- 更改環境變量PATH,增長mysql絕對路徑 mysqladmin -uroot password '123456' mysql -uroot -p123456
- 密碼重置 vi /etc/my.cnf//增長skip-grant
- 重啓mysql服務 /etc/init.d/mysqld restart
- mysql -uroot
- use mysql;
- update user set password=password('aminglinux') where user='root';
13.2 鏈接mysql
- mysql -uroot -p123456
- mysql -uroot -p123456 -h127.0.0.1 -P3306
- mysql -uroot -p123456 -S/tmp/mysql.sock
- mysql -uroot -p123456 -e 「show databases」
13.3 mysql經常使用命令
- 查詢庫 show databases;
- 切換庫 use mysql;
- 查看庫裏的表 show tables;
- 查看錶裏的字段 desc tb_name;
- 查看建表語句 show create table tb_name\G;
- 查看當前用戶 select user();
- 查看當前使用的數據庫 select databsase();
- 建立庫 create database db1;
- 建立表 use db1; create table t1(
id
int(4), name
char(40));
- 查看當前數據庫版本 select version();
- 查看數據庫狀態 show status;
- 查看各參數 show variables; show variables like 'max_connect%';
- 修改參數 set global max_connect_errors=1000;
- 查看隊列 show processlist; show full processlist;
擴展
- 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
歡迎關注本站公眾號,獲取更多信息