Linux CentOS6.5 yum安装mysql 5.6

Linux CentOS6.5 yum安装mysql 5.6

1.新开的云服务器,需要检测系统是否自带安装mysql

# yum list installed | grep mysql
2.如果发现有系统自带mysql,果断这么干

# yum -y remove mysql-libs.x86_64
3.随便在你存放文件的目录下执行,这里解释一下,由于这个mysql的yum源服务器在国外,所以下载速度会比较慢,还好mysql5.6只有79M大,而mysql5.7就有182M了,所以这是我不想安装mysql5.7的原因

# wget http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm
4.接着执行这句,解释一下,这个rpm还不是mysql的安装文件,只是两个yum源文件,执行后,在/etc/yum.repos.d/ 这个目录下多出mysql-community-source.repo和mysql-community.repo

# rpm -ivh mysql-community-release-el6-5.noarch.rpm
5.这个时候,可以用yum repolist mysql这个命令查看一下是否已经有mysql可安装文件

#yum repolist all | grep mysql
6.安装mysql 服务器命令(一路yes):

# yum install mysql-community-server
7.安装成功后

# service mysqld start
8.由于mysql刚刚安装完的时候,mysql的root用户的密码默认是空的,所以我们需要及时用mysql的root用户登录(第一次回车键,不用输入密码),并修改密码

# mysql -u root
# use mysql;
# update user set password=PASSWORD("这里输入root用户密码") where User='root';
# flush privileges; 
9.查看mysql是否自启动,并且设置开启自启动命令

 

# chkconfig --list | grep mysqld
# chkconfig mysqld on
10.mysql安全设置(系统会一路问你几个问题,看不懂复制之后翻译,基本上一路yes):

# mysql_secure_installation
此命令出现页面为:

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL 
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! 
In order to log into MySQL to secure it, we’ll need the current 
password for the root user. If you’ve just installed MySQL, and 
you haven’t set the root password yet, the password will be blank, 
so you should just press enter here.
Enter current password for root (enter for none): 
OK, successfully used password, moving on…
 
Setting the root password ensures that nobody can log into the MySQL 
root user without the proper authorisation. 
You already have a root password set, so you can safely answer ‘n’. 
Change the root password? [Y/n] y [设置root用户密码] 
New password: 
Re-enter new password: 
Password updated successfully! 
Reloading privilege tables.. 
… Success!
 
By default, a MySQL installation has an anonymous user, allowing anyone 
to log into MySQL without having to have a user account created for 
them. This is intended only for testing, and to make the installation 
go a bit smoother. You should remove them before moving into a 
production environment. 
Remove anonymous users? [Y/n] y [删除匿名用户] 
… Success! 
Normally, root should only be allowed to connect from ‘localhost’. This 
ensures that someone cannot guess at the root password from the network. 
Disallow root login remotely? [Y/n] n [禁止root远程登录] 
… skipping. 
By default, MySQL comes with a database named ‘test’ that anyone can 
access. This is also intended only for testing, and should be removed 
before moving into a production environment. 
Remove test database and access to it? [Y/n] y [删除test数据库] 
- Dropping test database… 
ERROR 1008 (HY000) at line 1: Can’t drop database ‘test’; database doesn’t exist 
… Failed! Not critical, keep moving… 
- Removing privileges on test database… 
… Success! 
Reloading the privilege tables will ensure that all changes made so far 
will take effect immediately. 
Reload privilege tables now? [Y/n] y [刷新权限] 
… Success! 
All done! If you’ve completed all of the above steps, your MySQL 
installation should now be secure. 
Thanks for using MySQL! 
Cleaning up… 
4、授权远程登录 
       (1)登录mysql数据库 Mysql -u root -p 

(2)授权登录 
  登录mysql之后执行 

use mysql;
这里的123456为你给新增权限用户设置的密码,%代表所有主机,也可以具体到你的主机ip地址

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456'  
刷新权限(刷新权限后不用重启,直接使用远程链接工具测试即可)

flush privileges; 
本人使用的是Vavicat


MySql授予远程远程权限具体详情请查看此篇文章 MySQL【远程用户】授权设置(一)
 
修改字符集为UTF-8:
vim /etc/my.cnf
在[mysqld]部分添加:

character-set-server=utf8
在文件末尾新增[client]段,并在[client]段添加:

default-character-set=utf8
 

已经安装完成了,同时,你需要登录阿里云服务器开放3306端口。开放端口找到你的服务器列表,选择安全策略,添加安全策略就可以了

 

CentOS 6.安装msyql 5.6参考文章:https://www.cnblogs.com/renjidong/p/7047396.html
CentOS 7.安装msyql5.6 或者5.7参考文章:https://blog.csdn.net/z13615480737/article/details/78906551

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值