1、先到MYSQL官网下载MYSQL数据库MySQL-5.6.2_m5-1.rhel5.i386.tar
2、解压MySQL-5.6.2_m5-1.rhel5.i386.tar
3、分别安装解压出来的6个RPM包
[root@lamp home]# tar xvf MySQL-5.6.2_m5-1.rhel5.i386.tar
MySQL-client-5.6.2_m5-1.rhel5.i386.rpm
MySQL-devel-5.6.2_m5-1.rhel5.i386.rpm
MySQL-embedded-5.6.2_m5-1.rhel5.i386.rpm
MySQL-server-5.6.2_m5-1.rhel5.i386.rpm
MySQL-shared-5.6.2_m5-1.rhel5.i386.rpm
MySQL-test-5.6.2_m5-1.rhel5.i386.rpm
[root@lamp home]# rpm -ivh MySQL-client-5.6.2_m5-1.rhel5.i386.rpm
Preparing... ########################################### [100%]
1:MySQL-client ########################################### [100%]
[root@lamp home]# rpm -ivh MySQL-devel-5.6.2_m5-1.rhel5.i386.rpm
Preparing... ########################################### [100%]
1:MySQL-devel ########################################### [100%]
[root@lamp home]# rpm -ivh MySQL-embedded-5.6.2_m5-1.rhel5.i386.rpm
Preparing... ########################################### [100%]
1:MySQL-embedded ########################################### [100%]
[root@lamp home]# rpm -ivh MySQL-shared-5.6.2_m5-1.rhel5.i386.rpm
Preparing... ########################################### [100%]
1:MySQL-shared ########################################### [100%]
[root@lamp home]# rpm -ivh MySQL-test-5.6.2_m5-1.rhel5.i386.rpm
Preparing... ########################################### [100%]
1:MySQL-test ########################################### [100%]
[root@lamp home]# rpm -ivh MySQL-server-5.6.2_m5-1.rhel5.i386.rpm
Preparing... ########################################### [100%]
1:MySQL-server ########################################### [100%]
120531 10:27:17 [Note] Binlog end
120531 10:27:17 [Note] Shutting down plugin 'partition'
120531 10:27:17 [Note] Shutting down plugin 'BLACKHOLE'
120531 10:27:17 [Note] Shutting down plugin 'ARCHIVE'
120531 10:27:17 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN_COLS'
120531 10:27:17 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN'
120531 10:27:17 [Note] Shutting down plugin 'INNODB_SYS_FIELDS'
120531 10:27:17 [Note] Shutting down plugin 'INNODB_SYS_COLUMNS'
120531 10:27:17 [Note] Shutting down plugin 'INNODB_SYS_INDEXES'
120531 10:27:17 [Note] Shutting down plugin 'INNODB_SYS_TABLESTATS'
120531 10:27:17 [Note] Shutting down plugin 'INNODB_SYS_TABLES'
120531 10:27:17 [Note] Shutting down plugin 'INNODB_METRICS'
120531 10:27:17 [Note] Shutting down plugin 'INNODB_BUFFER_POOL_STATS'
120531 10:27:17 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE_LRU'
120531 10:27:17 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE'
120531 10:27:17 [Note] Shutting down plugin 'INNODB_CMPMEM_RESET'
120531 10:27:17 [Note] Shutting down plugin 'INNODB_CMPMEM'
120531 10:27:17 [Note] Shutting down plugin 'INNODB_CMP_RESET'
120531 10:27:17 [Note] Shutting down plugin 'INNODB_CMP'
120531 10:27:17 [Note] Shutting down plugin 'INNODB_LOCK_WAITS'
120531 10:27:17 [Note] Shutting down plugin 'INNODB_LOCKS'
120531 10:27:17 [Note] Shutting down plugin 'INNODB_TRX'
120531 10:27:17 [Note] Shutting down plugin 'PERFORMANCE_SCHEMA'
120531 10:27:17 [Note] Shutting down plugin 'MEMORY'
120531 10:27:17 [Note] Shutting down plugin 'MyISAM'
120531 10:27:17 [Note] Shutting down plugin 'MRG_MYISAM'
120531 10:27:17 [Note] Shutting down plugin 'CSV'
120531 10:27:17 [Note] Shutting down plugin 'mysql_old_password'
120531 10:27:17 [Note] Shutting down plugin 'mysql_native_password'
120531 10:27:17 [Note] Shutting down plugin 'binlog'
120531 10:27:17 [Note] Binlog end
120531 10:27:17 [Note] Shutting down plugin 'partition'
120531 10:27:17 [Note] Shutting down plugin 'BLACKHOLE'
120531 10:27:17 [Note] Shutting down plugin 'ARCHIVE'
120531 10:27:17 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN_COLS'
120531 10:27:17 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN'
120531 10:27:17 [Note] Shutting down plugin 'INNODB_SYS_FIELDS'
120531 10:27:17 [Note] Shutting down plugin 'INNODB_SYS_COLUMNS'
120531 10:27:17 [Note] Shutting down plugin 'INNODB_SYS_INDEXES'
120531 10:27:17 [Note] Shutting down plugin 'INNODB_SYS_TABLESTATS'
120531 10:27:17 [Note] Shutting down plugin 'INNODB_SYS_TABLES'
120531 10:27:17 [Note] Shutting down plugin 'INNODB_METRICS'
120531 10:27:17 [Note] Shutting down plugin 'INNODB_BUFFER_POOL_STATS'
120531 10:27:17 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE_LRU'
120531 10:27:17 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE'
120531 10:27:17 [Note] Shutting down plugin 'INNODB_CMPMEM_RESET'
120531 10:27:17 [Note] Shutting down plugin 'INNODB_CMPMEM'
120531 10:27:17 [Note] Shutting down plugin 'INNODB_CMP_RESET'
120531 10:27:17 [Note] Shutting down plugin 'INNODB_CMP'
120531 10:27:17 [Note] Shutting down plugin 'INNODB_LOCK_WAITS'
120531 10:27:17 [Note] Shutting down plugin 'INNODB_LOCKS'
120531 10:27:17 [Note] Shutting down plugin 'INNODB_TRX'
120531 10:27:17 [Note] Shutting down plugin 'PERFORMANCE_SCHEMA'
120531 10:27:17 [Note] Shutting down plugin 'MEMORY'
120531 10:27:17 [Note] Shutting down plugin 'MyISAM'
120531 10:27:17 [Note] Shutting down plugin 'MRG_MYISAM'
120531 10:27:17 [Note] Shutting down plugin 'CSV'
120531 10:27:17 [Note] Shutting down plugin 'mysql_old_password'
120531 10:27:17 [Note] Shutting down plugin 'mysql_native_password'
120531 10:27:17 [Note] Shutting down plugin 'binlog'
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h lamp password 'new-password'
Alternatively you can run:
/usr/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
Please report any problems with the /usr/bin/mysqlbug script!
4、安装完成后启动MYSQL,并修改初始密码。
[root@lamp home]# service mysql start
Starting MySQL.. [确定]
[root@lamp home]# mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.2-m5 MySQL Community Server (GPL)
Copyright (c) 2000, 2010, 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.
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpwd');
Query OK, 0 rows affected (0.00 sec)
mysql> exit
Bye
一、允许root用户在任何地方进行远程登录,并具有所有库任何操作权限,具体操作如下:
在本机先使用root用户登录mysql:
mysql -u root -p"youpassword"
进行授权操作:
mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'youpassword' WITH GRANT OPTION;
重载授权表:
FLUSH PRIVILEGES;
退出mysql数据库:
exit
二、允许root用户在一个特定的IP进行远程登录,并具有所有库任何操作权限,具体操作如下:
在本机先使用root用户登录mysql:
mysql -u root -p"youpassword"
进行授权操作:
GRANT ALL PRIVILEGES ON *.* TO root@"172.16.16.152 " IDENTIFIED BY "youpassword" WITH GRANT OPTION;
重载授权表:
FLUSH PRIVILEGES;
退出mysql数据库:
exit
三、允许root用户在一个特定的IP进行远程登录,并具有所有库特定操作权限,具体操作如下:
在本机先使用root用户登录mysql:
mysql -u root -p"youpassword"
进行授权操作:
GRANT select,insert,update,delete ON *.* TO root@"172.16.16.152 " IDENTIFIED BY "youpassword";
重载授权表:
FLUSH PRIVILEGES;
退出mysql数据库:
exit
四、删除用户授权,需要使用REVOKE命令,具体命令格式为:
REVOKE privileges ON 数据库[.表名] FROM user-name;
具体实例,先在本机登录mysql:
mysql -u root -p"youpassword"
进行授权操作:
GRANT select,insert,update,delete ON TEST-DB TO test-user@"172.16.16.152 " IDENTIFIED BY "youpassword";
再进行删除授权操作:
REVOKE all on TEST-DB from test-user;
****注:该操作只是清除了用户对于TEST-DB的相关授权权限,但是这个“test-user”这个用户还是存在。
最后从用户表内清除用户:
DELETE FROM user WHERE user="test-user";
重载授权表:
FLUSH PRIVILEGES;
退出mysql数据库:
exit
本文出自 “实践” 博客,转载请与作者联系!