这时就可以使用客户端命令连接进来了
[iyunv@localhost mysql]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.28-log Source distribution
Copyright (c) 2000, 2012, 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> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.00 sec)
删除两个匿名用户和给管理员设置密码
mysql> DROP USER ''@localhost;
Query OK, 0 rows affected (0.00 sec)
mysql> DROP USER ''@'localhost.localdomain';
Query OK, 0 rows affected (0.00 sec)
mysql> UPdata user SET Password=PASSWORD('redhat') WHERE user='root';
如果不使用ipv6地址也可以把::1这个用户删除
mysql> DROP USER 'root'@'::1';
Query OK, 0 rows affected (0.00 sec)
退出mysql是在使用mysql命令就连接不进来了,要连接需要指定用户名和密码
[iyunv@localhost mysql]# mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
[iyunv@localhost mysql]# mysql -uroot -p
Enter password:
6.存储引擎设置
查看存储引擎
mysql> show engines;
1
2
3
4
5
6
7
8
9
10
11
12
13
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
| Engine | Support | Comment | Transactions | XA | Savepoints |
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
| MRG_MYISAM | YES | Collection of identical MyISAM tables | NO | NO | NO |
| InnoDB | DEFAULT | Supports transactions, row-level locking, and foreign keys | YES | YES | YES |
| CSV | YES | CSV storage engine | NO | NO | NO |
| BLACKHOLE | YES | /dev/null storage engine (anything you write to it disappears) | NO | NO | NO |
| MyISAM | YES | MyISAM storage engine | NO | NO | NO |
| PERFORMANCE_SCHEMA | YES | Performance Schema | NO | NO | NO |
| ARCHIVE | YES | Archive storage engine | NO | NO | NO |
| MEMORY | YES | Hash based, stored in memory, useful for temporary tables | NO | NO | NO |
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
8 rows in set (0.00 sec)
设置每个表使用一个独立的表空间文件
[iyunv@localhost mysql]# vim /etc/my.cnf
innodb_file_per_table = 1
[iyunv@localhost mysql]# service mysqld restart
mysql查看innodb_file_per_table 是否启用
mysql> SHOW GLOBAL VARIABLES LIKE '%innodb%';
innodb_file_per_table | ON