13.1 設置更改root密碼
13.2 鏈接mysql
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.htmlhtml
[root@yong-01 ~]# mysql -uroot -bash: mysql: 未找到命令 [root@yong-01 ~]# ls /usr/local/mysql/bin/mysql /usr/local/mysql/bin/mysql [root@yong-01 ~]# echo $PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin [root@yong-01 ~]# export PATH=$PATH:/usr/local/mysql/bin/
[root@yong-01 ~]# mysql -uroot Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.6.35 MySQL Community Server (GPL) Copyright (c) 2000, 2016, 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> quit Bye
[root@yong-01 ~]# mysqladmin -uroot password '123456' Warning: Using a password on the command line interface can be insecure.
[root@yong-01 ~]# mysql -uroot ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
[root@yong-01 ~]# mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g.
[root@yong-01 ~]# mysqladmin -uroot -p'123456' password '654321' Warning: Using a password on the command line interface can be insecure.
[root@yong-01 ~]# mysql -uroot -p'654321' Warning: Using a password on the command line interface can be insecure.
[root@yong-01 ~]# mysql -uroot Welcome to the MySQL monitor. Commands end with ; or \g.
mysql> use mysql; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql>
mysql> select password from user where user='root'; +-------------------------------------------+ | password | +-------------------------------------------+ | *2A032F7C5BA932872F0F045E0CF6B53CF702F2C5 | | | | | | | +-------------------------------------------+ 4 rows in set (0.05 sec)
密碼字段 函數 //用於加密密碼 高亮部分:爲條件語句 mysql> update user set password=password('111111') where user='root'; Query OK, 4 rows affected (0.00 sec) Rows matched: 4 Changed: 4 Warnings: 0
[root@yong-01 ~]# mysql -uroot -p'111111' -h127.0.0.1 -P3306
[root@yong-01 ~]# mysql -uroot -p'111111' -S/tmp/mysql.sock
[root@yong-01 ~]# mysql -uroot -p'111111' -e "show databases" Warning: Using a password on the command line interface can be insecure. +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | test | +--------------------+
id
int(4), name
char(40));mysql> create database db1; Query OK, 1 row affected (0.00 sec)
mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | db1 | | mysql | | performance_schema | | test | +--------------------+ 5 rows in set (0.00 sec)
mysql> use db1; Database changed
id
int(4), name
char(40));——>定義 id 和 name ,並用反引號括起來mysql> create table t1(`id` int(4), `name` char(40)); Query OK, 0 rows affected (0.03 sec)
mysql> show create table t1\G; *************************** 1. row *************************** Table: t1 Create Table: CREATE TABLE `t1` ( `id` int(4) DEFAULT NULL, `name` char(40) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 1 row in set (0.00 sec) ERROR: No query specified
mysql> drop table t1; Query OK, 0 rows affected (0.02 sec)
mysql> create table t1(`id` int(4), `name` char(40)) ENGINE=InnoDB DEFAULT CHARSET=utf8; Query OK, 0 rows affected (0.06 sec)
mysql> show create table t1\G; *************************** 1. row *************************** Table: t1 Create Table: CREATE TABLE `t1` ( `id` int(4) DEFAULT NULL, `name` char(40) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 1 row in set (0.00 sec) ERROR: No query specified
mysql> select version(); +-----------+ | version() | +-----------+ | 5.6.35 | +-----------+ 1 row in set (0.00 sec)
mysql> show variables like 'max_connect%'; +--------------------+-------+ | Variable_name | Value | +--------------------+-------+ | max_connect_errors | 100 | | max_connections | 151 | +--------------------+-------+ 2 rows in set (0.00 sec)
mysql> set global max_connect_errors=1000; Query OK, 0 rows affected (0.00 sec) mysql> show variables like 'max_connect%'; +--------------------+-------+ | Variable_name | Value | +--------------------+-------+ | max_connect_errors | 1000 | | max_connections | 151 | +--------------------+-------+ 2 rows in set (0.00 sec)
mysql> show processlist; +----+------+-----------+------+---------+------+-------+------------------+ | Id | User | Host | db | Command | Time | State | Info | +----+------+-----------+------+---------+------+-------+------------------+ | 5 | root | localhost | db1 | Query | 0 | init | show processlist | +----+------+-----------+------+---------+------+-------+------------------+ 1 row in set (0.00 sec)
mysql> show full processlist; +----+------+-----------+------+---------+------+-------+-----------------------+ | Id | User | Host | db | Command | Time | State | Info | +----+------+-----------+------+---------+------+-------+-----------------------+ | 14 | root | localhost | db1 | Query | 0 | init | show full processlist | +----+------+-----------+------+---------+------+-------+-----------------------+ 1 row in set (0.00 sec) mysql>