003 Linux下MySQL5.6.10的安装与配置(CentOS 6.8)

1、查看当前系统是否安装了mysql:
rpm -qa|grep -i mysql


2、卸载已安装的JDK
# rpm -e --nodeps 要卸载的mysql名称


删除老版本mysql的开发头文件和库
rm -fr /usr/lib/mysql
rm -fr /usr/include/mysql
注意:卸载后/var/lib/mysql中的数据及/etc/my.cnf不会删除,如果确定没用后就手工删除
rm -f /etc/my.cnf
rm -fr /var/lib/mysql


3、下载mysql的rpm包
可以通过wget下载具体的地址因为不能用链接请大家去官网去找
(1)MySQL-server-5.6.10-1.rhel5.x86_64.rpm:MySQL服务器;
(2)MySQL-client-5.6.10-1.rhel5.x86_64.rpm:MySQL客户端;
(3)MySQL-devel-5.6.10-1.rhel5.x86_64.rpm:Mysql开发依赖包。


4、安装mysql
# rpm -ivh MySQL-server-5.6.10-1.rhel5.x86_64.rpm
Preparing...                ########################################### [100%]
   1:MySQL-server           ########################################### [100%]
2016-06-24 11:24:57 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-06-24 11:24:57 6315 [Note] InnoDB: The InnoDB memory heap is disabled
2016-06-24 11:24:57 6315 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2016-06-24 11:24:57 6315 [Note] InnoDB: Compressed tables use zlib 1.2.3
2016-06-24 11:24:57 6315 [Note] InnoDB: CPU does not support crc32 instructions
2016-06-24 11:24:57 6315 [Note] InnoDB: Using Linux native AIO
2016-06-24 11:24:57 6315 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2016-06-24 11:24:57 6315 [Note] InnoDB: Completed initialization of buffer pool
2016-06-24 11:24:57 6315 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2016-06-24 11:24:57 6315 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
......


A RANDOM PASSWORD HAS BEEN SET FOR THE MySQL root USER !
You will find that password in '/root/.mysql_secret'.


You must change that password on your first connect,
no other statement but 'SET PASSWORD' will be accepted.
See the manual for the semantics of the 'password expired' flag.


Also, the account for the anonymous user has been removed.


In addition, you can run:


  /usr/bin/mysql_secure_installation


which will also give you the option of removing the test database.
This is strongly recommended for production servers.


See the manual for more instructions.


Please report any problems with the /usr/bin/mysqlbug script!


The latest information about MySQL is available on the web at


  http://www.mysql.com


Support MySQL by buying support/licenses at http://shop.mysql.com


New default config file was created as /usr/my.cnf and
will be used by default by the server when you start it.
You may edit this file to change server settings


# rpm -ivh MySQL-client-5.6.10-1.rhel5.x86_64.rpm
Preparing...                ########################################### [100%]
   1:MySQL-client           ########################################### [100%]


# rpm -ivh MySQL-devel-5.6.10-1.rhel5.x86_64.rpm
Preparing...                ########################################### [100%]
   1:MySQL-devel            ########################################### [100%]


5、启停mysql
service mysql start
或者
/etc/init.d/mysql start


6、修改密码
# cat /root/.mysql_secret
# The random password set for the root user at Fri Jun 24 11:24:58 2016 (local time): lUBvwPpg
# mysql -u root -p
Enter password: 
mysql> SET PASSWORD = PASSWORD('root');
Query OK, 0 rows affected (0.00 sec)


7、创建用户
create database jira736 default character set utf8 collate utf8_bin;
create user jira identified by 'jira';
grant all on jira736.* to 'jira'@'%' identified by 'jira';
grant select,insert,update,delete,create,drop on vtdc.employee to jira identified by 'jira';


8、登陆用户
mysql -ujira -pjira
mysql -h127.0.0.1 -ujira -pjira -P3306


9、查看MySQL系统
SHOW VARIABLES;
show databases;
use jira;
show tables;

猜你喜欢

转载自blog.csdn.net/guoyanliang1985/article/details/80090279