CentOS 7 yum安装MySQL5.6
2021/9/18 19:08:35
本文主要是介绍CentOS 7 yum安装MySQL5.6,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
众所周知,Linux系统自带的repo是不会自动更新每个软件的最新版本(基本都是比较靠后的稳定版),所以无法通过yum方式安装MySQL的高级版本。所以我们需要先安装带有当前可用的mysql5系列社区版资源的rpm包。
#安装rpm包
Bash[root@typecodes ~]# rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpmBash
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安装资源:
Bash[root@typecodes ~]# yum repolist enabled | grep "mysql.*-community.*"Bash
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版本了。
Bash[root@typecodes ~]# yum -y install mysql-community-server
3 MySQL安装完成后,进行相关配置
安装完MySQL后,需要进行一些基础配置工作:
#安装成功后,将其加入开机启动
Bash[root@typecodes ~]# systemctl enable mysqld
#启动mysql服务进程
Bash[root@typecodes ~]# systemctl start mysqld
#配置mysql(设置密码等)
Bash[root@typecodes ~]# mysql_secure_installationBash
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, andyou 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. 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 anyoneto log into MySQL without having to have a user account created forthem. 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] 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 removedbefore 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...
进入mysql
Bash# mysql -uroot -p
输入密码
Bashmysql>use mysql; mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
这篇关于CentOS 7 yum安装MySQL5.6的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-11-16MySQL资料:新手入门教程
- 2024-11-16MySQL资料:新手入门教程
- 2024-11-15MySQL教程:初学者必备的MySQL数据库入门指南
- 2024-11-15MySQL教程:初学者必看的MySQL入门指南
- 2024-11-04部署MySQL集群项目实战:新手入门教程
- 2024-11-04如何部署MySQL集群资料:新手入门指南
- 2024-11-02MySQL集群项目实战:新手入门指南
- 2024-11-02初学者指南:部署MySQL集群资料
- 2024-11-01部署MySQL集群教程:新手入门指南
- 2024-11-01如何部署MySQL集群:新手入门教程