阿里云的CentOS环境中安装配置MySQL的教程

http://www.jb51.net/article/76493.htm

众所周知,Linux系统自带的repo是不会自动更新每个软件的最新版本(基本都是比较靠后的稳定版),所以无法通过yum方式安装MySQL的高级版本。所以我们需要先安装带有当前可用的mysql5系列社区版资源的rpm包。

#######安装rpm包
[root@typecodes ~]# rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
Retrieving http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
Preparing...       ################################# [100%]
Updating / installing...
 1:mysql-community-release-el7-5 ################################# [100%]
这时查看当前可用的mysql安装资源:
[root@typecodes ~]# yum repolist enabled | grep "mysql.*-community.*"
mysql-connectors-community/x86_64 MySQL Connectors Community     14
mysql-tools-community/x86_64  MySQL Tools Community      17
mysql56-community/x86_64   MySQL 5.6 Community Server    139

从上面的列表可以看出, mysql56-community/x86_64 和 MySQL 5.6 Community Server 可以使用。

因此,我们就可以直接用yum方式安装了MySQL5.6版本了。

[root@typecodes ~]# yum -y install mysql-community-server
安装完MySQL后,需要进行一些基础配置工作:

#######安装成功后,将其加入开机启动
[root@typecodes ~]# systemctl enable mysqld
 
#######启动mysql服务进程
[root@typecodes ~]# systemctl start mysqld
 
#######配置mysql(设置密码等)
[root@typecodes ~]# mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
  SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
 这里需要注意的是,如果你是新安装的mysql,会弹出如下提示:
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键就可以了
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.
Set 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.
 大概意思是,mysql会默认创建一个匿名用户,方便你测试什么的,现在问你要不要删掉它,果断删掉
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.
 大概意思是,root用户默认只能访问localhost,以防止有人猜你的密码。。。问你是否禁止root登陆,也选yes,虽然基本上不会有人来猜吧。
Disallow root login remotely? [Y/n] y  [禁止root远程登录]
 ... Success!
 
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.
 大概意思是,mysql默认创建了一个名为test的数据库,这个库任何人都可以访问,问你是不是要把它删掉,也删掉。
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.
 大概意思是,上面所有的修改是否马上生效,选y
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...

skip-name-resolve
skip-external-locking
key_buffer_size = 256M
#table_cache = 3072
table_open_cache = 3072
read_buffer_size = 2M
read_rnd_buffer_size = 2M
sort_buffer_size = 2M
myisam_sort_buffer_size = 256M
thread_cache_size = 8
query_cache_size= 512M
query_cache_limit= 5M
tmp_table_size=1024M
max_heap_table_size=3000M
max_allowed_packet = 16M
innodb_buffer_pool_size = 512M
innodb_log_file_size = 512M
innodb_additional_mem_pool_size=512M
innodb_log_buffer_size=64M
max_connections=2000
max_user_connections=800
join_buffer_size = 8M
open_files_limit = 65535
#tmpdir=/dev/shm
max_connect_errors=1000

/usr/bin/mysql -uroot -p

#输入密码连接数据库

show databases;#查看数据库

use test;#使用某个数据库

show tables;#查看所有数据表







  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值