看错误日志
xtrabackup
./scripts/mysql_install_db
mysql -S /tmp/mysql.sock #进入mysql
root@localhost:mysql.sock 08:06:41 [(none)]>show databases
-> ;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.03 sec)
root@localhost:mysql.sock 08:07:41 [(none)]>select user,host,password from mysql.user;
+------+-----------------------+----------+
| user | host | password |
+------+-----------------------+----------+
| root | localhost | |
| root | localhost.localdomain | |
| root | 127.0.0.1 | |
| root | ::1 | |
| | localhost | |
| | localhost.localdomain | |
+------+-----------------------+----------+
6 rows in set (0.00 sec)
root@localhost:mysql.sock 08:08:10 [(none)]>delete from mysql.user where user!='root' or host!='localhost'
-> ;
Query OK, 5 rows affected (0.02 sec)
root@localhost:mysql.sock 08:09:32 [(none)]>select user,host,password from mysql.user;
+------+-----------+----------+
| user | host | password |
+------+-----------+----------+
| root | localhost | |
+------+-----------+----------+
1 row in set (0.00 sec)
root@localhost:mysql.sock 08:09:55 [(none)]>flush privileges;
Query OK, 0 rows affected (0.00 sec)
root@localhost:mysql.sock 08:10:38 [(none)]>select * from db
-> ;
ERROR 1046 (3D000): No database selected
root@localhost:mysql.sock 08:11:03 [(none)]>use mysql;
Database changed
root@localhost:mysql.sock 08:11:11 [mysql]>select * from db;
+------+---------+------+-------------+-------------+-------------+-------------+-------------+-----------+------------+-----------------+------------+------------+-----------------------+------------------+------------------+----------------+---------------------+--------------------+--------------+------------+--------------+
| Host | Db | User | Select_priv | Insert_priv | Update_priv | Delete_priv | Create_priv | Drop_priv | Grant_priv | References_priv | Index_priv | Alter_priv | Create_tmp_table_priv | Lock_tables_priv | Create_view_priv | Show_view_priv | Create_routine_priv | Alter_routine_priv | Execute_priv | Event_priv | Trigger_priv |
+------+---------+------+-------------+-------------+-------------+-------------+-------------+-----------+------------+-----------------+------------+------------+-----------------------+------------------+------------------+----------------+---------------------+--------------------+--------------+------------+--------------+
| % | test | | Y | Y | Y | Y | Y | Y | N | Y | Y | Y | Y | Y | Y | Y | Y | N | N | Y | Y |
| % | test\_% | | Y | Y | Y | Y | Y | Y | N | Y | Y | Y | Y | Y | Y | Y | Y | N | N | Y | Y |
+------+---------+------+-------------+-------------+-------------+-------------+-------------+-----------+------------+-----------------+------------+------------+-----------------------+------------------+------------------+----------------+---------------------+--------------------+--------------+------------+--------------+
2 rows in set (0.00 sec)
root@localhost:mysql.sock 08:11:19 [mysql]>truncate table db;
Query OK, 0 rows affected (0.02 sec)
root@localhost:mysql.sock 08:11:42 [mysql]>select * from db;
Empty set (0.00 sec)
root@localhost:mysql.sock 08:11:50 [mysql]>flush privileges;
Query OK, 0 rows affected (0.00 sec)
root@localhost:mysql.sock 08:11:56 [mysql]>grant all privileges on *.* to 'root'@'%' identified by 'you-password';
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id: 2
Current database: mysql
Query OK, 0 rows affected (0.00 sec)
root@localhost:mysql.sock 08:18:13 [mysql]>flush privileges;
Query OK, 0 rows affected (0.00 sec)
/etc/init.d/mysql stop
mysqladmin -S /tmp/mysql.sock shutdown -uroot -p
mysqladmin -S /tmp/mysql_3306.sock -uroot -p shutdown
mysqld_safe方式启动
/usr/local/mysql/bin/mysqld_safe –defaults-file=/etc/my.cnf &
mysqld方式启动
/usr/local/mysql/bin/mysqld –defaults-file=/etc/my.cnf &
这种方式一定要申明 data和user
5.6初始化ibdata
查询mysql进程
netstat -nalp | grep mysql
ps aux | grep mysql